<!DOCTYPE html><html lang="zh-CN" data-theme="light"><head><div id="myscoll"></div><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"><title>外部中断 | Certainly</title><meta name="keywords" content="学习,笔记"><meta name="author" content="Certainly"><meta name="copyright" content="Certainly"><meta name="format-detection" content="telephone=no"><meta name="theme-color" content="ffffff"><meta name="description" content="STM32学习笔记">
<meta property="og:type" content="article">
<meta property="og:title" content="外部中断">
<meta property="og:url" content="https://certainly.gitee.io/posts/29e72e31.html">
<meta property="og:site_name" content="Certainly">
<meta property="og:description" content="STM32学习笔记">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="https://source.fomal.cc/img/default_cover_14.webp">
<meta property="article:published_time" content="2023-08-23T13:34:21.000Z">
<meta property="article:modified_time" content="2023-08-23T13:39:20.375Z">
<meta property="article:author" content="Certainly">
<meta property="article:tag" content="学习">
<meta property="article:tag" content="笔记">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="https://source.fomal.cc/img/default_cover_14.webp"><link rel="shortcut icon" href="/"><link rel="canonical" href="https://certainly.gitee.io/posts/29e72e31"><link rel="preconnect" href="//cdn.jsdelivr.net"/><link rel="preconnect" href="//busuanzi.ibruce.info"/><link rel="stylesheet" href="/css/index.css"><link rel="stylesheet" href="https://lf6-cdn-tos.bytecdntp.com/cdn/expire-1-M/font-awesome/6.0.0/css/all.min.css" media="print" onload="this.media='all'"><link rel="stylesheet" href="https://cdn.staticfile.org/fancyapps-ui/4.0.31/fancybox.min.css" media="print" onload="this.media='all'"><script>const GLOBAL_CONFIG = { 
  root: '/',
  algolia: undefined,
  localSearch: {"path":"/search.xml","preload":true,"languages":{"hits_empty":"找不到您查询的内容：${query}"}},
  translate: undefined,
  noticeOutdate: {"limitDay":365,"position":"top","messagePrev":"It has been","messageNext":"days since the last update, the content of the article may be outdated."},
  highlight: {"plugin":"highlighjs","highlightCopy":true,"highlightLang":true,"highlightHeightLimit":230},
  copy: {
    success: '复制成功',
    error: '复制错误',
    noSupport: '浏览器不支持'
  },
  relativeDate: {
    homepage: true,
    post: true
  },
  runtime: '',
  date_suffix: {
    just: '刚刚',
    min: '分钟前',
    hour: '小时前',
    day: '天前',
    month: '个月前'
  },
  copyright: undefined,
  lightbox: 'fancybox',
  Snackbar: undefined,
  source: {
    justifiedGallery: {
      js: 'https://cdnjs.cloudflare.com/ajax/libs/flickr-justified-gallery/2.1.2/fjGallery.min.js',
      css: 'https://cdnjs.cloudflare.com/ajax/libs/flickr-justified-gallery/2.1.2/fjGallery.min.css'
    }
  },
  isPhotoFigcaption: false,
  islazyload: true,
  isAnchor: false
}</script><script id="config-diff">var GLOBAL_CONFIG_SITE = {
  title: '外部中断',
  isPost: true,
  isHome: false,
  isHighlightShrink: false,
  isToc: true,
  postUpdate: '2023-08-23 21:39:20'
}</script><noscript><style type="text/css">
  #nav {
    opacity: 1
  }
  .justified-gallery img {
    opacity: 1
  }

  #recent-posts time,
  #post-meta time {
    display: inline !important
  }
</style></noscript><script>(win=>{
    win.saveToLocal = {
      set: function setWithExpiry(key, value, ttl) {
        if (ttl === 0) return
        const now = new Date()
        const expiryDay = ttl * 86400000
        const item = {
          value: value,
          expiry: now.getTime() + expiryDay,
        }
        localStorage.setItem(key, JSON.stringify(item))
      },

      get: function getWithExpiry(key) {
        const itemStr = localStorage.getItem(key)

        if (!itemStr) {
          return undefined
        }
        const item = JSON.parse(itemStr)
        const now = new Date()

        if (now.getTime() > item.expiry) {
          localStorage.removeItem(key)
          return undefined
        }
        return item.value
      }
    }
  
    win.getScript = url => new Promise((resolve, reject) => {
      const script = document.createElement('script')
      script.src = url
      script.async = true
      script.onerror = reject
      script.onload = script.onreadystatechange = function() {
        const loadState = this.readyState
        if (loadState && loadState !== 'loaded' && loadState !== 'complete') return
        script.onload = script.onreadystatechange = null
        resolve()
      }
      document.head.appendChild(script)
    })
  
      win.activateDarkMode = function () {
        document.documentElement.setAttribute('data-theme', 'dark')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', '#0d0d0d')
        }
      }
      win.activateLightMode = function () {
        document.documentElement.setAttribute('data-theme', 'light')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', 'ffffff')
        }
      }
      const t = saveToLocal.get('theme')
    
          const now = new Date()
          const hour = now.getHours()
          const isNight = hour <= 6 || hour >= 18
          if (t === undefined) isNight ? activateDarkMode() : activateLightMode()
          else if (t === 'light') activateLightMode()
          else activateDarkMode()
        
      const asideStatus = saveToLocal.get('aside-status')
      if (asideStatus !== undefined) {
        if (asideStatus === 'hide') {
          document.documentElement.classList.add('hide-aside')
        } else {
          document.documentElement.classList.remove('hide-aside')
        }
      }
    
    const detectApple = () => {
      if(/iPad|iPhone|iPod|Macintosh/.test(navigator.userAgent)){
        document.documentElement.classList.add('apple')
      }
    }
    detectApple()
    })(window)</script><link rel="stylesheet" href="https://cdn1.tianli0.top/npm/element-ui@2.15.6/packages/theme-chalk/lib/index.css"><style id="themeColor"></style><style id="rightSide"></style><style id="transPercent"></style><style id="blurNum"></style><style id="settingStyle"></style><span id="fps"></span><style id="defineBg"></style><style id="menu_shadow"></style><svg aria-hidden="true" style="position:absolute; overflow:hidden; width:0; height:0"><symbol id="icon-sun" viewBox="0 0 1024 1024"><path d="M960 512l-128 128v192h-192l-128 128-128-128H192v-192l-128-128 128-128V192h192l128-128 128 128h192v192z" fill="#FFD878" p-id="8420"></path><path d="M736 512a224 224 0 1 0-448 0 224 224 0 1 0 448 0z" fill="#FFE4A9" p-id="8421"></path><path d="M512 109.248L626.752 224H800v173.248L914.752 512 800 626.752V800h-173.248L512 914.752 397.248 800H224v-173.248L109.248 512 224 397.248V224h173.248L512 109.248M512 64l-128 128H192v192l-128 128 128 128v192h192l128 128 128-128h192v-192l128-128-128-128V192h-192l-128-128z" fill="#4D5152" p-id="8422"></path><path d="M512 320c105.888 0 192 86.112 192 192s-86.112 192-192 192-192-86.112-192-192 86.112-192 192-192m0-32a224 224 0 1 0 0 448 224 224 0 0 0 0-448z" fill="#4D5152" p-id="8423"></path></symbol><symbol id="icon-moon" viewBox="0 0 1024 1024"><path d="M611.370667 167.082667a445.013333 445.013333 0 0 1-38.4 161.834666 477.824 477.824 0 0 1-244.736 244.394667 445.141333 445.141333 0 0 1-161.109334 38.058667 85.077333 85.077333 0 0 0-65.066666 135.722666A462.08 462.08 0 1 0 747.093333 102.058667a85.077333 85.077333 0 0 0-135.722666 65.024z" fill="#FFB531" p-id="11345"></path><path d="M329.728 274.133333l35.157333-35.157333a21.333333 21.333333 0 1 0-30.165333-30.165333l-35.157333 35.157333-35.114667-35.157333a21.333333 21.333333 0 0 0-30.165333 30.165333l35.114666 35.157333-35.114666 35.157334a21.333333 21.333333 0 1 0 30.165333 30.165333l35.114667-35.157333 35.157333 35.157333a21.333333 21.333333 0 1 0 30.165333-30.165333z" fill="#030835" p-id="11346"></path></symbol></svg><!-- hexo injector head_end start --><link rel="stylesheet" href="https://npm.elemecdn.com/hexo-butterfly-swiper/lib/swiper.min.css" media="print" onload="this.media='all'"><link rel="stylesheet" href="https://npm.elemecdn.com/hexo-butterfly-swiper/lib/swiperstyle.css" media="print" onload="this.media='all'"><link rel="stylesheet" href="https://npm.elemecdn.com/hexo-butterfly-tag-plugins-plus@latest/lib/assets/font-awesome-animation.min.css" media="defer" onload="this.media='all'"><link rel="stylesheet" href="https://npm.elemecdn.com/hexo-butterfly-tag-plugins-plus@latest/lib/tag_plugins.css" media="defer" onload="this.media='all'"><script src="https://npm.elemecdn.com/hexo-butterfly-tag-plugins-plus@latest/lib/assets/carousel-touch.js"></script><link rel="stylesheet" href="https://npm.elemecdn.com/hexo-butterfly-wowjs/lib/animate.min.css" media="print" onload="this.media='screen'"><link rel="stylesheet" href="https://npm.elemecdn.com/hexo-filter-gitcalendar/lib/gitcalendar.css" media="print" onload="this.media='all'"><!-- hexo injector head_end end --><meta name="generator" content="Hexo 6.3.0"><link rel="alternate" href="/atom.xml" title="Certainly" type="application/atom+xml">
</head><body><div id="loading-box" onclick="document.getElementById(&quot;loading-box&quot;).classList.add(&quot;loaded&quot;)"><div class="loading-bg"><div class="loading-img"></div><div class="loading-image-dot"></div></div></div><div id="web_bg"></div><div id="sidebar"><div id="menu-mask"></div><div id="sidebar-menus"><div class="avatar-img is-center"><img src= "" data-lazy-src="https://tuchuang.voooe.cn/images/2023/03/15/head.webp" onerror="onerror=null;src='/assets/r1.jpg'" alt="avatar"/></div><div class="sidebar-site-data site-data is-center"><a href="/archives/"><div class="headline">文章</div><div class="length-num">16</div></a><a href="/tags/"><div class="headline">标签</div><div class="length-num">5</div></a><a href="/categories/"><div class="headline">分类</div><div class="length-num">3</div></a></div><hr/><div class="menus_items"><div class="menus_item"><a class="site-page faa-parent animated-hover" href="/"><svg class="menu_icon faa-tada" aria-hidden="true" style="width:1.30em;height:1.30em;vertical-align:-0.15em;fill:currentColor;overflow:hidden;"><use xlink:href="#icon-home"></use></svg><span class="menu_word" style="font-size:17px"> 首页</span></a></div><div class="menus_item"><a class="site-page group faa-parent animated-hover hide" href="javascript:void(0);"><svg class="menu_icon faa-tada" aria-hidden="true" style="width:1.30em;height:1.30em;vertical-align:-0.15em;fill:currentColor;overflow:hidden;"><use xlink:href="#icon--article"></use></svg><span class="menu_word" style="font-size:17px"> 文章</span><i class="fas fa-chevron-down"></i></a><ul class="menus_item_child"><li><a class="site-page child faa-parent animated-hover" href="/archives/"><svg class="menu_icon faa-tada" aria-hidden="true" style="width:1.30em;height:1.30em;vertical-align:-0.15em;fill:currentColor;overflow:hidden;"><use xlink:href="#icon-guidang1">                   </use></svg><span class="menu_word" style="font-size:17px"> 归档</span></a></li><li><a class="site-page child faa-parent animated-hover" href="/tags/"><svg class="menu_icon faa-tada" aria-hidden="true" style="width:1.30em;height:1.30em;vertical-align:-0.15em;fill:currentColor;overflow:hidden;"><use xlink:href="#icon-sekuaibiaoqian">                   </use></svg><span class="menu_word" style="font-size:17px"> 标签</span></a></li><li><a class="site-page child faa-parent animated-hover" href="/categories/"><svg class="menu_icon faa-tada" aria-hidden="true" style="width:1.30em;height:1.30em;vertical-align:-0.15em;fill:currentColor;overflow:hidden;"><use xlink:href="#icon-fenlei">                   </use></svg><span class="menu_word" style="font-size:17px"> 分类</span></a></li></ul></div><div class="menus_item"><a class="site-page group faa-parent animated-hover hide" href="javascript:void(0);"><svg class="menu_icon faa-tada" aria-hidden="true" style="width:1.30em;height:1.30em;vertical-align:-0.15em;fill:currentColor;overflow:hidden;"><use xlink:href="#icon-pinweishenghuo"></use></svg><span class="menu_word" style="font-size:17px"> 休闲</span><i class="fas fa-chevron-down"></i></a><ul class="menus_item_child"><li><a class="site-page child faa-parent animated-hover" href="/life/music/"><svg class="menu_icon faa-tada" aria-hidden="true" style="width:1.30em;height:1.30em;vertical-align:-0.15em;fill:currentColor;overflow:hidden;"><use xlink:href="#icon-yinle">                   </use></svg><span class="menu_word" style="font-size:17px"> 八音盒</span></a></li><li><a class="site-page child faa-parent animated-hover" href="/life/movies/"><svg class="menu_icon faa-tada" aria-hidden="true" style="width:1.30em;height:1.30em;vertical-align:-0.15em;fill:currentColor;overflow:hidden;"><use xlink:href="#icon-dianying1">                   </use></svg><span class="menu_word" style="font-size:17px"> 影院</span></a></li><li><a class="site-page child faa-parent animated-hover" href="/life/games/"><svg class="menu_icon faa-tada" aria-hidden="true" style="width:1.30em;height:1.30em;vertical-align:-0.15em;fill:currentColor;overflow:hidden;"><use xlink:href="#icon-youxishoubing">                   </use></svg><span class="menu_word" style="font-size:17px"> 游戏</span></a></li></ul></div><div class="menus_item"><a class="site-page group faa-parent animated-hover hide" href="javascript:void(0);"><svg class="menu_icon faa-tada" aria-hidden="true" style="width:1.30em;height:1.30em;vertical-align:-0.15em;fill:currentColor;overflow:hidden;"><use xlink:href="#icon-xiangzi"></use></svg><span class="menu_word" style="font-size:17px"> 八宝箱</span><i class="fas fa-chevron-down"></i></a><ul class="menus_item_child"><li><a class="site-page child faa-parent animated-hover" href="/box/gallery/"><svg class="menu_icon faa-tada" aria-hidden="true" style="width:1.30em;height:1.30em;vertical-align:-0.15em;fill:currentColor;overflow:hidden;"><use xlink:href="#icon-tubiaozhizuomoban">                   </use></svg><span class="menu_word" style="font-size:17px"> 画廊</span></a></li><li><a class="site-page child faa-parent animated-hover" href="/box/animation/"><svg class="menu_icon faa-tada" aria-hidden="true" style="width:1.30em;height:1.30em;vertical-align:-0.15em;fill:currentColor;overflow:hidden;"><use xlink:href="#icon-nvwumao">                   </use></svg><span class="menu_word" style="font-size:17px"> 动画</span></a></li><li><a class="site-page child faa-parent animated-hover" href="/box/nav/"><svg class="menu_icon faa-tada" aria-hidden="true" style="width:1.30em;height:1.30em;vertical-align:-0.15em;fill:currentColor;overflow:hidden;"><use xlink:href="#icon-zhifengche">                   </use></svg><span class="menu_word" style="font-size:17px"> 网址导航</span></a></li></ul></div><div class="menus_item"><a class="site-page group faa-parent animated-hover hide" href="javascript:void(0);"><svg class="menu_icon faa-tada" aria-hidden="true" style="width:1.30em;height:1.30em;vertical-align:-0.15em;fill:currentColor;overflow:hidden;"><use xlink:href="#icon-shejiaoxinxi"></use></svg><span class="menu_word" style="font-size:17px"> 社交</span><i class="fas fa-chevron-down"></i></a><ul class="menus_item_child"><li><a class="site-page child faa-parent animated-hover" href="/social/fcircle/"><svg class="menu_icon faa-tada" aria-hidden="true" style="width:1.30em;height:1.30em;vertical-align:-0.15em;fill:currentColor;overflow:hidden;"><use xlink:href="#icon-pengyouquan">                   </use></svg><span class="menu_word" style="font-size:17px"> 朋友圈</span></a></li><li><a class="site-page child faa-parent animated-hover" href="/comments/"><svg class="menu_icon faa-tada" aria-hidden="true" style="width:1.30em;height:1.30em;vertical-align:-0.15em;fill:currentColor;overflow:hidden;"><use xlink:href="#icon-liuyan">                   </use></svg><span class="menu_word" style="font-size:17px"> 留言板</span></a></li><li><a class="site-page child faa-parent animated-hover" href="/social/link/"><svg class="menu_icon faa-tada" aria-hidden="true" style="width:1.30em;height:1.30em;vertical-align:-0.15em;fill:currentColor;overflow:hidden;"><use xlink:href="#icon-lianjie">                   </use></svg><span class="menu_word" style="font-size:17px"> 友人帐</span></a></li></ul></div><div class="menus_item"><a class="site-page group faa-parent animated-hover hide" href="javascript:void(0);"><svg class="menu_icon faa-tada" aria-hidden="true" style="width:1.30em;height:1.30em;vertical-align:-0.15em;fill:currentColor;overflow:hidden;"><use xlink:href="#icon-wangye"></use></svg><span class="menu_word" style="font-size:17px"> 网站</span><i class="fas fa-chevron-down"></i></a><ul class="menus_item_child"><li><a class="site-page child faa-parent animated-hover" href="/site/census/"><svg class="menu_icon faa-tada" aria-hidden="true" style="width:1.30em;height:1.30em;vertical-align:-0.15em;fill:currentColor;overflow:hidden;"><use xlink:href="#icon--tongjibiao">                   </use></svg><span class="menu_word" style="font-size:17px"> 网站统计</span></a></li><li><a class="site-page child faa-parent animated-hover" href="/site/echarts/"><svg class="menu_icon faa-tada" aria-hidden="true" style="width:1.30em;height:1.30em;vertical-align:-0.15em;fill:currentColor;overflow:hidden;"><use xlink:href="#icon-shujutongji1">                   </use></svg><span class="menu_word" style="font-size:17px"> 文章统计</span></a></li><li><a class="site-page child faa-parent animated-hover" href="/site/time/"><svg class="menu_icon faa-tada" aria-hidden="true" style="width:1.30em;height:1.30em;vertical-align:-0.15em;fill:currentColor;overflow:hidden;"><use xlink:href="#icon-xianxingshalou">                   </use></svg><span class="menu_word" style="font-size:17px"> 旧时光</span></a></li></ul></div><div class="menus_item"><a class="site-page group faa-parent animated-hover hide" href="javascript:void(0);"><svg class="menu_icon faa-tada" aria-hidden="true" style="width:1.30em;height:1.30em;vertical-align:-0.15em;fill:currentColor;overflow:hidden;"><use xlink:href="#icon-maoliang"></use></svg><span class="menu_word" style="font-size:17px"> 个人</span><i class="fas fa-chevron-down"></i></a><ul class="menus_item_child"><li><a class="site-page child faa-parent animated-hover" href="/personal/bb/"><svg class="menu_icon faa-tada" aria-hidden="true" style="width:1.30em;height:1.30em;vertical-align:-0.15em;fill:currentColor;overflow:hidden;"><use xlink:href="#icon-qunliaotian">                   </use></svg><span class="menu_word" style="font-size:17px"> 唠叨</span></a></li><li><a class="site-page child faa-parent animated-hover" href="/personal/about/"><svg class="menu_icon faa-tada" aria-hidden="true" style="width:1.30em;height:1.30em;vertical-align:-0.15em;fill:currentColor;overflow:hidden;"><use xlink:href="#icon-paperplane">                   </use></svg><span class="menu_word" style="font-size:17px"> 关于</span></a></li></ul></div></div></div></div><div class="post" id="body-wrap"><header class="post-bg" id="page-header"><nav id="nav"><span id="blog_name"><a id="site-name" href="/">Certainly</a></span><div id="menus"><div class="menus_items"><div class="menus_item"><a class="site-page faa-parent animated-hover" href="/"><svg class="menu_icon faa-tada" aria-hidden="true" style="width:1.30em;height:1.30em;vertical-align:-0.15em;fill:currentColor;overflow:hidden;"><use xlink:href="#icon-home"></use></svg><span class="menu_word" style="font-size:17px"> 首页</span></a></div><div class="menus_item"><a class="site-page group faa-parent animated-hover hide" href="javascript:void(0);"><svg class="menu_icon faa-tada" aria-hidden="true" style="width:1.30em;height:1.30em;vertical-align:-0.15em;fill:currentColor;overflow:hidden;"><use xlink:href="#icon--article"></use></svg><span class="menu_word" style="font-size:17px"> 文章</span><i class="fas fa-chevron-down"></i></a><ul class="menus_item_child"><li><a class="site-page child faa-parent animated-hover" href="/archives/"><svg class="menu_icon faa-tada" aria-hidden="true" style="width:1.30em;height:1.30em;vertical-align:-0.15em;fill:currentColor;overflow:hidden;"><use xlink:href="#icon-guidang1">                   </use></svg><span class="menu_word" style="font-size:17px"> 归档</span></a></li><li><a class="site-page child faa-parent animated-hover" href="/tags/"><svg class="menu_icon faa-tada" aria-hidden="true" style="width:1.30em;height:1.30em;vertical-align:-0.15em;fill:currentColor;overflow:hidden;"><use xlink:href="#icon-sekuaibiaoqian">                   </use></svg><span class="menu_word" style="font-size:17px"> 标签</span></a></li><li><a class="site-page child faa-parent animated-hover" href="/categories/"><svg class="menu_icon faa-tada" aria-hidden="true" style="width:1.30em;height:1.30em;vertical-align:-0.15em;fill:currentColor;overflow:hidden;"><use xlink:href="#icon-fenlei">                   </use></svg><span class="menu_word" style="font-size:17px"> 分类</span></a></li></ul></div><div class="menus_item"><a class="site-page group faa-parent animated-hover hide" href="javascript:void(0);"><svg class="menu_icon faa-tada" aria-hidden="true" style="width:1.30em;height:1.30em;vertical-align:-0.15em;fill:currentColor;overflow:hidden;"><use xlink:href="#icon-pinweishenghuo"></use></svg><span class="menu_word" style="font-size:17px"> 休闲</span><i class="fas fa-chevron-down"></i></a><ul class="menus_item_child"><li><a class="site-page child faa-parent animated-hover" href="/life/music/"><svg class="menu_icon faa-tada" aria-hidden="true" style="width:1.30em;height:1.30em;vertical-align:-0.15em;fill:currentColor;overflow:hidden;"><use xlink:href="#icon-yinle">                   </use></svg><span class="menu_word" style="font-size:17px"> 八音盒</span></a></li><li><a class="site-page child faa-parent animated-hover" href="/life/movies/"><svg class="menu_icon faa-tada" aria-hidden="true" style="width:1.30em;height:1.30em;vertical-align:-0.15em;fill:currentColor;overflow:hidden;"><use xlink:href="#icon-dianying1">                   </use></svg><span class="menu_word" style="font-size:17px"> 影院</span></a></li><li><a class="site-page child faa-parent animated-hover" href="/life/games/"><svg class="menu_icon faa-tada" aria-hidden="true" style="width:1.30em;height:1.30em;vertical-align:-0.15em;fill:currentColor;overflow:hidden;"><use xlink:href="#icon-youxishoubing">                   </use></svg><span class="menu_word" style="font-size:17px"> 游戏</span></a></li></ul></div><div class="menus_item"><a class="site-page group faa-parent animated-hover hide" href="javascript:void(0);"><svg class="menu_icon faa-tada" aria-hidden="true" style="width:1.30em;height:1.30em;vertical-align:-0.15em;fill:currentColor;overflow:hidden;"><use xlink:href="#icon-xiangzi"></use></svg><span class="menu_word" style="font-size:17px"> 八宝箱</span><i class="fas fa-chevron-down"></i></a><ul class="menus_item_child"><li><a class="site-page child faa-parent animated-hover" href="/box/gallery/"><svg class="menu_icon faa-tada" aria-hidden="true" style="width:1.30em;height:1.30em;vertical-align:-0.15em;fill:currentColor;overflow:hidden;"><use xlink:href="#icon-tubiaozhizuomoban">                   </use></svg><span class="menu_word" style="font-size:17px"> 画廊</span></a></li><li><a class="site-page child faa-parent animated-hover" href="/box/animation/"><svg class="menu_icon faa-tada" aria-hidden="true" style="width:1.30em;height:1.30em;vertical-align:-0.15em;fill:currentColor;overflow:hidden;"><use xlink:href="#icon-nvwumao">                   </use></svg><span class="menu_word" style="font-size:17px"> 动画</span></a></li><li><a class="site-page child faa-parent animated-hover" href="/box/nav/"><svg class="menu_icon faa-tada" aria-hidden="true" style="width:1.30em;height:1.30em;vertical-align:-0.15em;fill:currentColor;overflow:hidden;"><use xlink:href="#icon-zhifengche">                   </use></svg><span class="menu_word" style="font-size:17px"> 网址导航</span></a></li></ul></div><div class="menus_item"><a class="site-page group faa-parent animated-hover hide" href="javascript:void(0);"><svg class="menu_icon faa-tada" aria-hidden="true" style="width:1.30em;height:1.30em;vertical-align:-0.15em;fill:currentColor;overflow:hidden;"><use xlink:href="#icon-shejiaoxinxi"></use></svg><span class="menu_word" style="font-size:17px"> 社交</span><i class="fas fa-chevron-down"></i></a><ul class="menus_item_child"><li><a class="site-page child faa-parent animated-hover" href="/social/fcircle/"><svg class="menu_icon faa-tada" aria-hidden="true" style="width:1.30em;height:1.30em;vertical-align:-0.15em;fill:currentColor;overflow:hidden;"><use xlink:href="#icon-pengyouquan">                   </use></svg><span class="menu_word" style="font-size:17px"> 朋友圈</span></a></li><li><a class="site-page child faa-parent animated-hover" href="/comments/"><svg class="menu_icon faa-tada" aria-hidden="true" style="width:1.30em;height:1.30em;vertical-align:-0.15em;fill:currentColor;overflow:hidden;"><use xlink:href="#icon-liuyan">                   </use></svg><span class="menu_word" style="font-size:17px"> 留言板</span></a></li><li><a class="site-page child faa-parent animated-hover" href="/social/link/"><svg class="menu_icon faa-tada" aria-hidden="true" style="width:1.30em;height:1.30em;vertical-align:-0.15em;fill:currentColor;overflow:hidden;"><use xlink:href="#icon-lianjie">                   </use></svg><span class="menu_word" style="font-size:17px"> 友人帐</span></a></li></ul></div><div class="menus_item"><a class="site-page group faa-parent animated-hover hide" href="javascript:void(0);"><svg class="menu_icon faa-tada" aria-hidden="true" style="width:1.30em;height:1.30em;vertical-align:-0.15em;fill:currentColor;overflow:hidden;"><use xlink:href="#icon-wangye"></use></svg><span class="menu_word" style="font-size:17px"> 网站</span><i class="fas fa-chevron-down"></i></a><ul class="menus_item_child"><li><a class="site-page child faa-parent animated-hover" href="/site/census/"><svg class="menu_icon faa-tada" aria-hidden="true" style="width:1.30em;height:1.30em;vertical-align:-0.15em;fill:currentColor;overflow:hidden;"><use xlink:href="#icon--tongjibiao">                   </use></svg><span class="menu_word" style="font-size:17px"> 网站统计</span></a></li><li><a class="site-page child faa-parent animated-hover" href="/site/echarts/"><svg class="menu_icon faa-tada" aria-hidden="true" style="width:1.30em;height:1.30em;vertical-align:-0.15em;fill:currentColor;overflow:hidden;"><use xlink:href="#icon-shujutongji1">                   </use></svg><span class="menu_word" style="font-size:17px"> 文章统计</span></a></li><li><a class="site-page child faa-parent animated-hover" href="/site/time/"><svg class="menu_icon faa-tada" aria-hidden="true" style="width:1.30em;height:1.30em;vertical-align:-0.15em;fill:currentColor;overflow:hidden;"><use xlink:href="#icon-xianxingshalou">                   </use></svg><span class="menu_word" style="font-size:17px"> 旧时光</span></a></li></ul></div><div class="menus_item"><a class="site-page group faa-parent animated-hover hide" href="javascript:void(0);"><svg class="menu_icon faa-tada" aria-hidden="true" style="width:1.30em;height:1.30em;vertical-align:-0.15em;fill:currentColor;overflow:hidden;"><use xlink:href="#icon-maoliang"></use></svg><span class="menu_word" style="font-size:17px"> 个人</span><i class="fas fa-chevron-down"></i></a><ul class="menus_item_child"><li><a class="site-page child faa-parent animated-hover" href="/personal/bb/"><svg class="menu_icon faa-tada" aria-hidden="true" style="width:1.30em;height:1.30em;vertical-align:-0.15em;fill:currentColor;overflow:hidden;"><use xlink:href="#icon-qunliaotian">                   </use></svg><span class="menu_word" style="font-size:17px"> 唠叨</span></a></li><li><a class="site-page child faa-parent animated-hover" href="/personal/about/"><svg class="menu_icon faa-tada" aria-hidden="true" style="width:1.30em;height:1.30em;vertical-align:-0.15em;fill:currentColor;overflow:hidden;"><use xlink:href="#icon-paperplane">                   </use></svg><span class="menu_word" style="font-size:17px"> 关于</span></a></li></ul></div></div><center id="name-container"><a id="page-name" href="javascript:scrollToTop()">PAGE_NAME</a></center><div id="nav-right"><div id="search-button"><a class="search faa-parent animated-hover" title="检索站内任何你想要的信息"><svg class="faa-tada icon" style="height:24px;width:24px;fill:currentColor;position:relative;top:6px" aria-hidden="true"><use xlink:href="#icon-valentine_-search-love-find-heart"></use></svg><span> 搜索</span></a></div><a class="meihua faa-parent animated-hover" onclick="toggleWinbox()" title="美化设置-自定义你的风格" id="meihua-button"><svg class="faa-tada icon" style="height:26px;width:26px;fill:currentColor;position:relative;top:8px" aria-hidden="true"><use xlink:href="#icon-tupian1"></use></svg></a><a class="sun_moon faa-parent animated-hover" onclick="switchNightMode()" title="浅色和深色模式转换" id="nightmode-button"><svg class="faa-tada" style="height:25px;width:25px;fill:currentColor;position:relative;top:7px" viewBox="0 0 1024 1024"><use id="modeicon" xlink:href="#icon-moon">       </use></svg></a><div id="toggle-menu"><a><i class="fas fa-bars fa-fw"></i></a></div></div></div></nav><div id="post-info"><h1 class="post-title">外部中断</h1><div id="post-meta"><div class="meta-firstline"><span class="post-meta-date"><svg class="meta_icon post-meta-icon" style="width:30px;height:30px;position:relative;top:10px"><use xlink:href="#icon-rili"></use></svg><span class="post-meta-label">发表于 </span><time class="post-meta-date-created" datetime="2023-08-23T13:34:21.000Z" title="发表于 2023-08-23 21:34:21">2023-08-23</time><span class="post-meta-separator">|</span><svg class="meta_icon post-meta-icon" style="width:18px;height:18px;position:relative;top:5px"><use xlink:href="#icon-gengxin1"></use></svg><span class="post-meta-label">更新于</span><time class="post-meta-date-updated" datetime="2023-08-23T13:39:20.375Z" title="更新于 2023-08-23 21:39:20">2023-08-23</time></span><span class="post-meta-categories"><span class="post-meta-separator">|</span><svg class="meta_icon post-meta-icon" style="width:18px;height:18px;position:relative;top:5px"><use xlink:href="#icon-biaoqian"></use></svg><a class="post-meta-categories" href="/categories/%E5%B5%8C%E5%85%A5%E5%BC%8F/">嵌入式</a></span></div><div class="meta-secondline"><span class="post-meta-separator">|</span><span class="post-meta-wordcount"><svg class="meta_icon post-meta-icon" style="width:25px;height:25px;position:relative;top:8px"><use xlink:href="#icon-charuword"></use></svg><span class="post-meta-label">字数总计:</span><span class="word-count">2553</span><span class="post-meta-separator">|</span><svg class="meta_icon post-meta-icon" style="width:20px;height:20px;position:relative;top:5px"><use xlink:href="#icon-shizhong"></use></svg><span class="post-meta-label">阅读时长:</span><span>11分钟</span></span><span class="post-meta-separator">|</span><span class="post-meta-pv-cv" id="" data-flag-title="外部中断"><svg class="meta_icon post-meta-icon" style="width:25px;height:25px;position:relative;top:5px"><use xlink:href="#icon-eye"></use></svg><span class="post-meta-label">阅读量:</span><span id="busuanzi_value_page_pv"><i class="fa-solid fa-spinner fa-spin"></i></span></span></div></div></div><section class="main-hero-waves-area waves-area"><svg class="waves-svg" xmlns="http://www.w3.org/2000/svg" xlink="http://www.w3.org/1999/xlink" viewBox="0 24 150 28" preserveAspectRatio="none" shape-rendering="auto"><defs><path id="gentle-wave" d="M -160 44 c 30 0 58 -18 88 -18 s 58 18 88 18 s 58 -18 88 -18 s 58 18 88 18 v 44 h -352 Z"></path></defs><g class="parallax"><use href="#gentle-wave" x="48" y="0"></use><use href="#gentle-wave" x="48" y="3"></use><use href="#gentle-wave" x="48" y="5"></use><use href="#gentle-wave" x="48" y="7"></use></g></svg></section></header><main class="layout" id="content-inner"><div id="post"><article class="post-content" id="article-container"><h3 id="一、异常与中断">一、异常与中断</h3>
<h4 id="（一）概述">（一）概述</h4>
<p>《Cortex M3与M4权威指南》章节4.5 P104</p>
<p><em>Exceptions are events that cause changes to program flow. When one happens, the processor suspends the current executing task and executes a part of the program called the exception handler. After the execution of the exception handler is completed, the processor then resumes normal program execution. In the ARM architecture, interrupts are one type of exception. Interrupts are usually generated from peripheral or external inputs, and in some cases they can be triggered by software. The exception handlers for interrupts are also referred to as Interrupt Service Routines (ISR)。</em></p>
<p><em>Each exception source has an exception number. <font color='red'>Exception numbers 1 to 15  as system exceptions, and exceptions 16 and above are for <strong>interrupts</strong>.</font> The design of the NVIC in the Cortex-M3 and Cortex-M4 processors can support up to 240 interrupt inputs. However, in practice the number of interrupt inputs imple mented in the design is far less, typically in the range of 16 to 100. In this way the silicon size of the design can be reduced, which also reduces power consumption.</em></p>
<p><img src= "" data-lazy-src="https://note.youdao.com/yws/public/resource/e2eac0dd45493be783e77563084fc9c3/xmlnote/AFD206D19B8E48AAB3D301C19EC04161/826547F35E8F434CB05179CF70E09C34/12685" alt="https://note.youdao.com/yws/public/resource/e2eac0dd45493be783e77563084fc9c3/xmlnote/AFD206D19B8E48AAB3D301C19EC04161/826547F35E8F434CB05179CF70E09C34/12685"></p>
<p>Nested vectored interrupt controller (NVIC)</p>
<p>The NVIC is a part of the Cortex-M processor. It is programmable and its registers are located in the System Control Space (SCS) of the memory map</p>
<p>The NVIC handles the exceptions and interrupt configurations, prioritization, and interrupt masking. The NVIC has the following features:</p>
<p>• Flexible exception and interrupt management</p>
<p>• Nested exception/interrupt support</p>
<p>• Vectored exception/interrupt entry</p>
<p>• Interrupt masking</p>
<h4 id="（二）异常类型">（二）异常类型</h4>
<p>《Cortex M3与M4权威指南》章节7.2 P232</p>
<h5 id="1-系统异常">1.系统异常</h5>
<p><img src= "" data-lazy-src="https://note.youdao.com/yws/public/resource/e2eac0dd45493be783e77563084fc9c3/xmlnote/AFD206D19B8E48AAB3D301C19EC04161/B7A908558D574710A7F87C4502E86BD7/12668" alt="https://note.youdao.com/yws/public/resource/e2eac0dd45493be783e77563084fc9c3/xmlnote/AFD206D19B8E48AAB3D301C19EC04161/B7A908558D574710A7F87C4502E86BD7/12668"></p>
<h5 id="2-中断">2.中断</h5>
<p><img src= "" data-lazy-src="https://note.youdao.com/yws/public/resource/e2eac0dd45493be783e77563084fc9c3/xmlnote/AFD206D19B8E48AAB3D301C19EC04161/8C4EC0A1617D4F498AF477D113583B0F/12682" alt="https://note.youdao.com/yws/public/resource/e2eac0dd45493be783e77563084fc9c3/xmlnote/AFD206D19B8E48AAB3D301C19EC04161/8C4EC0A1617D4F498AF477D113583B0F/12682"></p>
<h4 id="（三）中断控制">（三）中断控制</h4>
<p>《Cortex M3与M4权威指南》章节7.3 P235</p>
<p><img src= "" data-lazy-src="https://note.youdao.com/yws/public/resource/e2eac0dd45493be783e77563084fc9c3/xmlnote/AFD206D19B8E48AAB3D301C19EC04161/0B3757C257CB447A919ECF25BD2977EF/12657" alt="https://note.youdao.com/yws/public/resource/e2eac0dd45493be783e77563084fc9c3/xmlnote/AFD206D19B8E48AAB3D301C19EC04161/0B3757C257CB447A919ECF25BD2977EF/12657"></p>
<p><em>After reset, all interrupts are disabled and given a priority-level value of 0. Before using any interrupts, you need to:</em></p>
<ul>
<li><em>Set up the priority level of the required interrupt (this step is optional)</em></li>
<li><em>Enable the interrupt generation control in the peripheral that triggers the interrupt</em></li>
<li><em>Enable the interrupt in the NVIC</em></li>
</ul>
<p><em>In most typical applications, this is all you need to do. When the interrupt triggers, the corresponding Interrupt Service Routine (ISR) will execute (you might need to clear the interrupt request from the peripheral within the handler). The name of the ISR can be found inside the vector table inside the startup code, which is also provided by the microcontroller vendor. <strong>The name of the ISR needs to match the name</strong> <strong>used in the vector table</strong> <strong>so that the linker can place the starting address of the ISR into the vector table correctly.</strong></em></p>
<h5 id="3-向量表（Vector-table）">3.向量表（Vector table）</h5>
<p>《Cortex M3与M4权威指南》章节4.5.3 P107</p>
<p><em>When an exception event takes place and is accepted by the processor core, the corresponding exception handler is executed. To determine the starting address of the exception handler, a vector table mechanism is used. The vector table is an array of word data inside the system memory, each representing the starting address of one exception type。</em></p>
<h3 id="二、ARM-Cortex-M4-的中断体系">二、ARM Cortex-M4 的中断体系</h3>
<h4 id="1、定义">1、定义</h4>
<p>中断，意味着<strong>中途****打断</strong>现在干的事情，要立即处理紧急的事件。</p>
<p>现实的例子：手机玩游戏的时候，突然来电话。在编程当中还常遇到实时接收数据的请求，都使用中断服务函数，示例如下：</p>
<p><img src= "" data-lazy-src="https://note.youdao.com/yws/public/resource/e2eac0dd45493be783e77563084fc9c3/xmlnote/AFD206D19B8E48AAB3D301C19EC04161/415798FE1ED64B81B3F0905F1663CB27/12689" alt="https://note.youdao.com/yws/public/resource/e2eac0dd45493be783e77563084fc9c3/xmlnote/AFD206D19B8E48AAB3D301C19EC04161/415798FE1ED64B81B3F0905F1663CB27/12689"></p>
<h4 id="2">2.</h4>
<p>多达 140 个 GPIO（STM32F405xx/07xx 和 STM32F415xx/17xx）通过以下方式连接到 16 个外部中断/事件线。</p>
<p>例如：PA0占用了EXTI0，其他PB0~PI0是不能使用的。</p>
<p><img src= "" data-lazy-src="https://note.youdao.com/yws/public/resource/e2eac0dd45493be783e77563084fc9c3/xmlnote/AFD206D19B8E48AAB3D301C19EC04161/A7D3A237424E459FA5205593EBB923DA/12660" alt="https://note.youdao.com/yws/public/resource/e2eac0dd45493be783e77563084fc9c3/xmlnote/AFD206D19B8E48AAB3D301C19EC04161/A7D3A237424E459FA5205593EBB923DA/12660"></p>
<p><strong>引脚编号</strong>决定了对应<strong>哪个外部中断</strong>。</p>
<h4 id="二、代码思路">二、代码思路</h4>
<p>1.8051单片机</p>
<p>外部中断的触发方式：低电平触发、下降沿触发 IT0=1</p>
<p>允许外部中断引脚申请中断请求 EX0=1</p>
<p>优先级的配置</p>
<p>中断服务函数</p>
<p>2.STM32</p>
<p>端口A硬件时钟使能</p>
<p>SYSCFG硬件时钟使能</p>
<p>配置引脚的工作模式</p>
<p>将引脚连接到外部中断</p>
<p>中断触发方式：电平触发、边沿触发</p>
<p>允许外部中断引脚申请中断请求</p>
<p>优先级的配置</p>
<p>中断服务函数</p>
<p>注：</p>
<p>中断服务函数是不能被<strong>调用</strong>，编写格式<strong>不能随意编写</strong>，这是它特有的存在形式。不同的硬件平台，其编写方法是不一样的。</p>
<h4 id="三、函数接口">三、函数接口</h4>
<h5 id="1-为引脚选择使用哪个中断">1.为引脚选择使用哪个中断</h5>
<figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">/**</span></span><br><span class="line"><span class="comment">  * @brief  Selects the GPIO pin used as EXTI Line.</span></span><br><span class="line"><span class="comment">  * @param  EXTI_PortSourceGPIOx : selects the GPIO port to be used as source for</span></span><br><span class="line"><span class="comment">  *          EXTI lines where x can be (A..K) for STM32F42xxx/43xxx devices, (A..I) </span></span><br><span class="line"><span class="comment">  *          for STM32F405xx/407xx and STM32F415xx/417xx devices or (A, B, C, D and H)</span></span><br><span class="line"><span class="comment">  *          for STM32401xx devices.  </span></span><br><span class="line"><span class="comment">  *            </span></span><br><span class="line"><span class="comment">  * @param  EXTI_PinSourcex: specifies the EXTI line to be configured.</span></span><br><span class="line"><span class="comment">  *           This parameter can be EXTI_PinSourcex where x can be (0..15, except</span></span><br><span class="line"><span class="comment">  *           for EXTI_PortSourceGPIOI x can be (0..11) for STM32F405xx/407xx</span></span><br><span class="line"><span class="comment">  *           and STM32F405xx/407xx devices and for EXTI_PortSourceGPIOK x can   </span></span><br><span class="line"><span class="comment">  *           be (0..7) for STM32F42xxx/43xxx devices. </span></span><br><span class="line"><span class="comment">  *             </span></span><br><span class="line"><span class="comment">  * @retval None</span></span><br><span class="line"><span class="comment">  */</span></span><br><span class="line"><span class="type">void</span> <span class="title function_">SYSCFG_EXTILineConfig</span><span class="params">(<span class="type">uint8_t</span> EXTI_PortSourceGPIOx, <span class="type">uint8_t</span> EXTI_PinSourcex)</span></span><br></pre></td></tr></table></figure>
<h5 id="2-配置外部中断">2.配置外部中断</h5>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">/**</span></span><br><span class="line"><span class="comment">  * <span class="doctag">@brief</span>  Initializes the EXTI peripheral according to the specified</span></span><br><span class="line"><span class="comment">  *         parameters in the EXTI_InitStruct.</span></span><br><span class="line"><span class="comment">  * <span class="doctag">@param</span>  EXTI_InitStruct: pointer to a EXTI_InitTypeDef structure</span></span><br><span class="line"><span class="comment">  *         that contains the configuration information for the EXTI peripheral.</span></span><br><span class="line"><span class="comment">  * <span class="doctag">@retval</span> None</span></span><br><span class="line"><span class="comment">  */</span></span><br><span class="line"><span class="keyword">void</span> <span class="title function_">EXTI_Init</span><span class="params">(EXTI_InitTypeDef* EXTI_InitStruct)</span></span><br></pre></td></tr></table></figure>
<h5 id="3-中断优先级配置">3.中断优先级配置</h5>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">/**</span></span><br><span class="line"><span class="comment">  * <span class="doctag">@brief</span>  Initializes the NVIC peripheral according to the specified</span></span><br><span class="line"><span class="comment">  *         parameters in the NVIC_InitStruct.</span></span><br><span class="line"><span class="comment">  * <span class="doctag">@note</span>   To configure interrupts priority correctly, the NVIC_PriorityGroupConfig()</span></span><br><span class="line"><span class="comment">  *         function should be called before. </span></span><br><span class="line"><span class="comment">  * <span class="doctag">@param</span>  NVIC_InitStruct: pointer to a NVIC_InitTypeDef structure that contains</span></span><br><span class="line"><span class="comment">  *         the configuration information for the specified NVIC peripheral.</span></span><br><span class="line"><span class="comment">  * <span class="doctag">@retval</span> None</span></span><br><span class="line"><span class="comment">  */</span></span><br><span class="line"><span class="keyword">void</span> <span class="title function_">NVIC_Init</span><span class="params">(NVIC_InitTypeDef* NVIC_InitStruct)</span></span><br></pre></td></tr></table></figure>
<h5 id="4-获取外部中断状态">4.获取外部中断状态</h5>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">/**</span></span><br><span class="line"><span class="comment">  * <span class="doctag">@brief</span>  Checks whether the specified EXTI line is asserted or not.</span></span><br><span class="line"><span class="comment">  * <span class="doctag">@param</span>  EXTI_Line: specifies the EXTI line to check.</span></span><br><span class="line"><span class="comment">  *          This parameter can be EXTI_Linex where x can be(0..22)</span></span><br><span class="line"><span class="comment">  * <span class="doctag">@retval</span> The new state of EXTI_Line (SET or RESET).</span></span><br><span class="line"><span class="comment">  */</span></span><br><span class="line">ITStatus <span class="title function_">EXTI_GetITStatus</span><span class="params">(uint32_t EXTI_Line)</span></span><br></pre></td></tr></table></figure>
<h5 id="5-清空外部中断标志位">5.清空外部中断标志位</h5>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">/**</span></span><br><span class="line"><span class="comment">  * <span class="doctag">@brief</span>  Clears the EXTI&#x27;s line pending bits.</span></span><br><span class="line"><span class="comment">  * <span class="doctag">@param</span>  EXTI_Line: specifies the EXTI lines to clear.</span></span><br><span class="line"><span class="comment">  *          This parameter can be any combination of EXTI_Linex where x can be (0..22)</span></span><br><span class="line"><span class="comment">  * <span class="doctag">@retval</span> None</span></span><br><span class="line"><span class="comment">  */</span></span><br><span class="line"><span class="keyword">void</span> <span class="title function_">EXTI_ClearITPendingBit</span><span class="params">(uint32_t EXTI_Line)</span></span><br></pre></td></tr></table></figure>
<h3 id="三、中断优先级">三、中断优先级</h3>
<p>中断优先级的一个意义：出现多个中断同时触发，但是不能同时处理，所以<strong>先后顺序</strong>之分，要根据实际上的运行环境优先处理重要的中断。</p>
<h4 id="1-概述">1.概述</h4>
<p>STM32 对中断优先级进行分组，共 5 组，组 0~4，这些分组是用于指定当前M4支持多少个抢占优先级和多少个响应优先级。同时，对每个中断设置一个抢占优先级和一个响应优先级。函数原型如下：</p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">/**</span></span><br><span class="line"><span class="comment">  * <span class="doctag">@brief</span>  Configures the priority grouping: pre-emption priority and subpriority.</span></span><br><span class="line"><span class="comment">  * <span class="doctag">@param</span>  NVIC_PriorityGroup: specifies the priority grouping bits length. </span></span><br><span class="line"><span class="comment">  *   This parameter can be one of the following values:</span></span><br><span class="line"><span class="comment">  *     <span class="doctag">@arg</span> NVIC_PriorityGroup_0: 0 bits for pre-emption priority    //不支持抢占优先级</span></span><br><span class="line"><span class="comment">  *                                4 bits for subpriority             //支持16个响应优先级</span></span><br><span class="line"><span class="comment">  *     <span class="doctag">@arg</span> NVIC_PriorityGroup_1: 1 bits for pre-emption priority    //支持2个抢占优先级</span></span><br><span class="line"><span class="comment">  *                                3 bits for subpriority             //支持8个响应优先级</span></span><br><span class="line"><span class="comment">  *     <span class="doctag">@arg</span> NVIC_PriorityGroup_2: 2 bits for pre-emption priority    //支持4个抢占优先级</span></span><br><span class="line"><span class="comment">  *                                2 bits for subpriority             //支持4个响应优先级</span></span><br><span class="line"><span class="comment">  *     <span class="doctag">@arg</span> NVIC_PriorityGroup_3: 3 bits for pre-emption priority    //支持8个抢占优先级</span></span><br><span class="line"><span class="comment">  *                                1 bits for subpriority             //支持2个响应优先级</span></span><br><span class="line"><span class="comment">  *     <span class="doctag">@arg</span> NVIC_PriorityGroup_4: 4 bits for pre-emption priority    //支持16个抢占优先级</span></span><br><span class="line"><span class="comment">  *                                0 bits for subpriority             //不支持响应优先级</span></span><br><span class="line"><span class="comment">  * <span class="doctag">@note</span>   When the NVIC_PriorityGroup_0 is selected, IRQ pre-emption is no more possible. </span></span><br><span class="line"><span class="comment">  *         The pending IRQ priority will be managed only by the subpriority. </span></span><br><span class="line"><span class="comment">  * <span class="doctag">@retval</span> None</span></span><br><span class="line"><span class="comment">  */</span></span><br><span class="line"><span class="keyword">void</span> <span class="title function_">NVIC_PriorityGroupConfig</span><span class="params">(uint32_t， NVIC_PriorityGroup)</span></span><br></pre></td></tr></table></figure>
<p>只要开机初始化一次就可以了。</p>
<h4 id="2-抢占优先级与响应优先级区别">2.抢占优先级与响应优先级区别</h4>
<h5 id="1-高抢占优先级是可以打断正在进行的低抢占优先级的中断。抢占优先级若相同，则不会出现抢占的过程。">1)高抢占优先级是可以打断正在进行的低抢占优先级的中断。抢占优先级若相同，则不会出现抢占的过程。</h5>
<p>​    <img src= "" data-lazy-src="https://note.youdao.com/yws/public/resource/e2eac0dd45493be783e77563084fc9c3/xmlnote/AFD206D19B8E48AAB3D301C19EC04161/775CF73D47A94D5BA8ED00B65BF05858/12697" alt="0"></p>
<h5 id="2-抢占优先级相同的中断，高响应优先级不可以打断低响应优先级的中断。">2)抢占优先级相同的中断，高响应优先级不可以打断低响应优先级的中断。</h5>
<p>​    <img src= "" data-lazy-src="https://note.youdao.com/yws/public/resource/e2eac0dd45493be783e77563084fc9c3/xmlnote/AFD206D19B8E48AAB3D301C19EC04161/D8AC0DAE11C24ED8803546F365351468/12677" alt="0"></p>
<h5 id="3-抢占优先级相同的中断，当两个中断同时发生的情况下，哪个响应优先级高，哪个先执行。">3)抢占优先级相同的中断，当两个中断同时发生的情况下，哪个响应优先级高，哪个先执行。</h5>
<p>​    <img src= "" data-lazy-src="https://note.youdao.com/yws/public/resource/e2eac0dd45493be783e77563084fc9c3/xmlnote/AFD206D19B8E48AAB3D301C19EC04161/8A6AF218F3974E1F92056784715A985B/12693" alt="0"></p>
<h5 id="4-抢占优先级相同且响应优先级相同的中断，假如同时发生，会按照硬件内部固定的优先级执行，如下图。">4)抢占优先级相同且响应优先级相同的中断，假如同时发生，会按照硬件内部固定的优先级执行，如下图。</h5>
<p>​    <img src= "" data-lazy-src="https://note.youdao.com/yws/public/resource/e2eac0dd45493be783e77563084fc9c3/xmlnote/AFD206D19B8E48AAB3D301C19EC04161/6FF424CCC8EC485A8C4819CAAD8FB0E7/12672" alt="0"></p>
<p>​    <img src= "" data-lazy-src="https://note.youdao.com/yws/public/resource/e2eac0dd45493be783e77563084fc9c3/xmlnote/AFD206D19B8E48AAB3D301C19EC04161/7BF5498F993D4FED964A600A1693BBBE/12654" alt="0"></p>
<h5 id="5-无论是抢占优先级还是响应优先级，优先级数值越小，就代表优先级越高。">5)无论是抢占优先级还是响应优先级，优先级数值越小，就代表优先级越高。</h5>
<h3 id="四、中断服务函数">四、中断服务函数</h3>
<p>中断服务函数要简单、高效完成，以下的delay函数是为了方便观察中断现象，在实际项目开发过程，是不会这么做的。</p>
<p><img src= "" data-lazy-src="https://note.youdao.com/yws/public/resource/e2eac0dd45493be783e77563084fc9c3/xmlnote/AFD206D19B8E48AAB3D301C19EC04161/3A6A7975A1754784A1A7B7E36E3C9373/12680" alt="https://note.youdao.com/yws/public/resource/e2eac0dd45493be783e77563084fc9c3/xmlnote/AFD206D19B8E48AAB3D301C19EC04161/3A6A7975A1754784A1A7B7E36E3C9373/12680"></p>
<h3 id="五、应用场景">五、应用场景</h3>
<p>1.触摸屏坐标检测</p>
<p>2.数据接收完成立即通知处理</p>
<h3 id="操作流程">操作流程</h3>
<figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br></pre></td><td class="code"><pre><span class="line">	EXTI_InitTypeDef EXTI_Initstructure;	<span class="comment">//使用外部中断结构体</span></span><br><span class="line">	NVIC_InitTypeDef NVIC_Initstructure;	<span class="comment">//使用内部中断结构体</span></span><br><span class="line">	</span><br><span class="line">	<span class="comment">//定义中断初始化函数</span></span><br><span class="line">	<span class="type">void</span> <span class="title function_">exti0_init</span><span class="params">(<span class="type">void</span>)</span></span><br><span class="line">	&#123;</span><br><span class="line">        <span class="comment">//使能外设控制时钟</span></span><br><span class="line">        RCC_APB2PeriphClockCmd(RCC_APB2Periph_SYSCFG,ENABLE);</span><br><span class="line">        <span class="comment">//连接IO口与外部中断线</span></span><br><span class="line">		SYSCFG_EXTILineConfig(EXTI_PortSourceGPIOx,EXTI_PinSourcex);	</span><br><span class="line">        </span><br><span class="line">		EXTI_Initstructure.EXTI_Line = EXTI_Line0;					<span class="comment">//外部中断线0</span></span><br><span class="line">		EXTI_Initstructure.EXTI_Mode = EXTI_Mode_Interrupt;			<span class="comment">//设置为中断模式</span></span><br><span class="line">		EXTI_Initstructure.EXTI_Trigger = EXTI_Trigger_Rising;			<span class="comment">//设置为上升沿触发</span></span><br><span class="line">		EXTI_Initstructure.EXTI_LineCmd = ENABLE;						<span class="comment">//使能中断</span></span><br><span class="line">		EXTI_Init(&amp;EXTI_Initstructure);					<span class="comment">//中断初始化</span></span><br><span class="line">	</span><br><span class="line">	</span><br><span class="line">		NVIC_Initstructure.NVIC_IRQChannel = EXTI0_IRQn;				<span class="comment">//设置中断通道</span></span><br><span class="line">		NVIC_Initstructure.NVIC_IRQChannelPreemptionPriority =<span class="number">0X03</span>;		<span class="comment">//抢占优先级</span></span><br><span class="line">		NVIC_Initstructure.NVIC_IRQChannelSubPriority = <span class="number">0X03</span>;			<span class="comment">//响应优先级</span></span><br><span class="line">		NVIC_Initstructure.NVIC_IRQChannelCmd = ENABLE;					<span class="comment">//使能通道</span></span><br><span class="line">		NVIC_Init(&amp;NVIC_Initstructure);</span><br><span class="line">	</span><br><span class="line">	&#125;</span><br><span class="line"><span class="comment">//主函数</span></span><br><span class="line">	<span class="type">int</span> <span class="title function_">main</span><span class="params">(<span class="type">void</span>)</span></span><br><span class="line">    &#123;</span><br><span class="line">        <span class="comment">//配置中断优先级</span></span><br><span class="line">        NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);</span><br><span class="line">	</span><br><span class="line">		exti0_init();</span><br><span class="line">        </span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line"><span class="comment">//配置外部中断函数</span></span><br><span class="line"><span class="type">void</span> <span class="title function_">EXTI0_IRQHandler</span><span class="params">(<span class="type">void</span>)</span></span><br><span class="line">&#123;</span><br><span class="line">	<span class="comment">//检测标志位</span></span><br><span class="line">	<span class="keyword">if</span>(EXTI_GetITStatus(EXTI_Line0) != RESET)</span><br><span class="line">	&#123;</span><br><span class="line">		<span class="comment">//点灯</span></span><br><span class="line">		PFout(<span class="number">9</span>)=<span class="number">0</span>;</span><br><span class="line">		<span class="comment">//延时</span></span><br><span class="line">		delay();</span><br><span class="line">		</span><br><span class="line">		<span class="comment">//熄灭</span></span><br><span class="line">		PFout(<span class="number">9</span>)=<span class="number">1</span>;</span><br><span class="line">		</span><br><span class="line">		<span class="comment">//清除标志位</span></span><br><span class="line">		EXTI_ClearITPendingBit(EXTI_Line0);</span><br><span class="line">	&#125;</span><br><span class="line"></span><br><span class="line"></span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<h3 id="练习">练习</h3>
<h4 id="【中断练习】">【中断练习】</h4>
<figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br><span class="line">80</span><br><span class="line">81</span><br><span class="line">82</span><br><span class="line">83</span><br><span class="line">84</span><br><span class="line">85</span><br><span class="line">86</span><br><span class="line">87</span><br><span class="line">88</span><br><span class="line">89</span><br><span class="line">90</span><br><span class="line">91</span><br><span class="line">92</span><br><span class="line">93</span><br><span class="line">94</span><br><span class="line">95</span><br><span class="line">96</span><br><span class="line">97</span><br><span class="line">98</span><br><span class="line">99</span><br><span class="line">100</span><br><span class="line">101</span><br><span class="line">102</span><br><span class="line">103</span><br><span class="line">104</span><br><span class="line">105</span><br><span class="line">106</span><br><span class="line">107</span><br><span class="line">108</span><br><span class="line">109</span><br><span class="line">110</span><br><span class="line">111</span><br><span class="line">112</span><br><span class="line">113</span><br><span class="line">114</span><br><span class="line">115</span><br><span class="line">116</span><br><span class="line">117</span><br><span class="line">118</span><br><span class="line">119</span><br><span class="line">120</span><br><span class="line">121</span><br><span class="line">122</span><br><span class="line">123</span><br><span class="line">124</span><br><span class="line">125</span><br><span class="line">126</span><br><span class="line">127</span><br><span class="line">128</span><br><span class="line">129</span><br><span class="line">130</span><br><span class="line">131</span><br><span class="line">132</span><br><span class="line">133</span><br><span class="line">134</span><br><span class="line">135</span><br><span class="line">136</span><br><span class="line">137</span><br><span class="line">138</span><br><span class="line">139</span><br><span class="line">140</span><br><span class="line">141</span><br><span class="line">142</span><br><span class="line">143</span><br><span class="line">144</span><br><span class="line">145</span><br><span class="line">146</span><br><span class="line">147</span><br><span class="line">148</span><br><span class="line">149</span><br><span class="line">150</span><br><span class="line">151</span><br><span class="line">152</span><br><span class="line">153</span><br><span class="line">154</span><br><span class="line">155</span><br><span class="line">156</span><br><span class="line">157</span><br><span class="line">158</span><br><span class="line">159</span><br><span class="line">160</span><br><span class="line">161</span><br><span class="line">162</span><br><span class="line">163</span><br><span class="line">164</span><br><span class="line">165</span><br><span class="line">166</span><br><span class="line">167</span><br><span class="line">168</span><br><span class="line">169</span><br><span class="line">170</span><br><span class="line">171</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#<span class="keyword">include</span> <span class="string">&quot;sys.h&quot;</span></span></span><br><span class="line"></span><br><span class="line"></span><br><span class="line"></span><br><span class="line">	GPIO_InitTypeDef GPIO_Initstructure;</span><br><span class="line">	EXTI_InitTypeDef EXTI_Initstructure;</span><br><span class="line">	NVIC_InitTypeDef NVIC_Initstructure;</span><br><span class="line"></span><br><span class="line"><span class="type">void</span> <span class="title function_">delay</span><span class="params">(<span class="type">void</span>)</span></span><br><span class="line">&#123;</span><br><span class="line">	<span class="type">uint32_t</span> num=<span class="number">0x200000</span>;</span><br><span class="line">	<span class="keyword">while</span>(num--);</span><br><span class="line"></span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"></span><br><span class="line"><span class="type">void</span> <span class="title function_">exti0_init</span><span class="params">(<span class="type">void</span>)</span></span><br><span class="line">&#123;</span><br><span class="line">	<span class="comment">//端口E硬件时钟使能</span></span><br><span class="line">	RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOE,ENABLE);</span><br><span class="line">	<span class="comment">//端口E系统时钟使能</span></span><br><span class="line">	RCC_APB2PeriphClockCmd(RCC_APB2Periph_SYSCFG,ENABLE);</span><br><span class="line">	<span class="comment">//设置端口PE4</span></span><br><span class="line">	GPIO_Initstructure.GPIO_Pin = GPIO_Pin_4 ;</span><br><span class="line">	<span class="comment">//设置输入模式</span></span><br><span class="line">	GPIO_Initstructure.GPIO_Mode = GPIO_Mode_IN;</span><br><span class="line">	<span class="comment">//设置端口高速频率</span></span><br><span class="line">	GPIO_Initstructure.GPIO_Speed = GPIO_Speed_100MHz;</span><br><span class="line">	<span class="comment">//电阻上拉</span></span><br><span class="line">	GPIO_Initstructure.GPIO_PuPd =	GPIO_PuPd_UP;</span><br><span class="line">	<span class="comment">//初始化端口</span></span><br><span class="line">	GPIO_Init(GPIOE,&amp;GPIO_Initstructure);</span><br><span class="line">	</span><br><span class="line"></span><br><span class="line">	<span class="comment">//将PE4与和EXIT0连接</span></span><br><span class="line">	SYSCFG_EXTILineConfig(EXTI_PortSourceGPIOE,EXTI_PinSource4);	</span><br><span class="line">	</span><br><span class="line">	EXTI_Initstructure.EXTI_Line = EXTI_Line0;					<span class="comment">//外部中断线0</span></span><br><span class="line">	EXTI_Initstructure.EXTI_Mode = EXTI_Mode_Interrupt;			<span class="comment">//设置为中断模式</span></span><br><span class="line">	EXTI_Initstructure.EXTI_Trigger = EXTI_Trigger_Rising;			<span class="comment">//设置为上升沿触发</span></span><br><span class="line">	EXTI_Initstructure.EXTI_LineCmd = ENABLE;						<span class="comment">//使能中断</span></span><br><span class="line">	EXTI_Init(&amp;EXTI_Initstructure);					<span class="comment">//中断初始化</span></span><br><span class="line">	</span><br><span class="line">	</span><br><span class="line">	NVIC_Initstructure.NVIC_IRQChannel = EXTI0_IRQn;				<span class="comment">//设置中断通道</span></span><br><span class="line">	NVIC_Initstructure.NVIC_IRQChannelPreemptionPriority =<span class="number">0X03</span>;		<span class="comment">//抢占优先级</span></span><br><span class="line">	NVIC_Initstructure.NVIC_IRQChannelSubPriority = <span class="number">0X03</span>;			<span class="comment">//响应优先级</span></span><br><span class="line">	NVIC_Initstructure.NVIC_IRQChannelCmd = ENABLE;					<span class="comment">//使能通道</span></span><br><span class="line">	NVIC_Init(&amp;NVIC_Initstructure);</span><br><span class="line"></span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="type">void</span> <span class="title function_">exti1_init</span><span class="params">(<span class="type">void</span>)</span></span><br><span class="line">&#123;</span><br><span class="line">			<span class="comment">//端口A硬件时钟使能</span></span><br><span class="line">	RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOA,ENABLE);</span><br><span class="line">	<span class="comment">//端口E系统时钟使能</span></span><br><span class="line">	RCC_APB2PeriphClockCmd(RCC_APB2Periph_SYSCFG,ENABLE);</span><br><span class="line"></span><br><span class="line">	GPIO_Initstructure.GPIO_Pin = GPIO_Pin_0 ;</span><br><span class="line">	<span class="comment">//设置输入模式</span></span><br><span class="line">	GPIO_Initstructure.GPIO_Mode = GPIO_Mode_IN;</span><br><span class="line"></span><br><span class="line">	<span class="comment">//设置端口高速频率</span></span><br><span class="line">	GPIO_Initstructure.GPIO_Speed = GPIO_Speed_100MHz;</span><br><span class="line">	GPIO_Initstructure.GPIO_PuPd =	GPIO_PuPd_DOWN;</span><br><span class="line">	<span class="comment">//初始化端口</span></span><br><span class="line">	GPIO_Init(GPIOA,&amp;GPIO_Initstructure);</span><br><span class="line">	</span><br><span class="line"></span><br><span class="line">	<span class="comment">//将PA0与中断线1连接</span></span><br><span class="line">	SYSCFG_EXTILineConfig(EXTI_PortSourceGPIOA,EXTI_PinSource0);	</span><br><span class="line">	</span><br><span class="line">	EXTI_Initstructure.EXTI_Line = EXTI_Line1;					<span class="comment">//外部中断1</span></span><br><span class="line">	EXTI_Initstructure.EXTI_Mode = EXTI_Mode_Interrupt;			<span class="comment">//设置为中断模式</span></span><br><span class="line">	EXTI_Initstructure.EXTI_Trigger = EXTI_Trigger_Rising;			<span class="comment">//设置为上升沿触发</span></span><br><span class="line">	EXTI_Initstructure.EXTI_LineCmd = ENABLE;						<span class="comment">//使能中断</span></span><br><span class="line">	EXTI_Init(&amp;EXTI_Initstructure);</span><br><span class="line">	</span><br><span class="line">	</span><br><span class="line">	NVIC_Initstructure.NVIC_IRQChannel = EXTI1_IRQn;				<span class="comment">//设置中断通道</span></span><br><span class="line">	NVIC_Initstructure.NVIC_IRQChannelPreemptionPriority =<span class="number">0X02</span>;		<span class="comment">//抢占优先级</span></span><br><span class="line">	NVIC_Initstructure.NVIC_IRQChannelSubPriority = <span class="number">0X03</span>;			<span class="comment">//响应优先级</span></span><br><span class="line">	NVIC_Initstructure.NVIC_IRQChannelCmd = ENABLE;					<span class="comment">//使能通道</span></span><br><span class="line">	NVIC_Init(&amp;NVIC_Initstructure);</span><br><span class="line"></span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"></span><br><span class="line"><span class="type">int</span> <span class="title function_">main</span><span class="params">(<span class="type">void</span>)</span>	</span><br><span class="line">&#123;</span><br><span class="line">	<span class="comment">//LED</span></span><br><span class="line">	<span class="comment">//使能GPIOF</span></span><br><span class="line">	RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOF, ENABLE);</span><br><span class="line">	</span><br><span class="line">	<span class="comment">//使能端口PF9和PF10</span></span><br><span class="line">	GPIO_Initstructure.GPIO_Pin = GPIO_Pin_9 | GPIO_Pin_10;</span><br><span class="line">	<span class="comment">//设置输出模式</span></span><br><span class="line">	GPIO_Initstructure.GPIO_Mode = GPIO_Mode_OUT;</span><br><span class="line">	<span class="comment">//设置推挽输出</span></span><br><span class="line">	GPIO_Initstructure.GPIO_OType = GPIO_OType_PP;</span><br><span class="line">	<span class="comment">//设置上拉电阻</span></span><br><span class="line">	GPIO_Initstructure.GPIO_PuPd =	GPIO_PuPd_UP;</span><br><span class="line">	<span class="comment">//设置端口高速频率</span></span><br><span class="line">	GPIO_Initstructure.GPIO_Speed = GPIO_Speed_100MHz;</span><br><span class="line"></span><br><span class="line">	<span class="comment">//初始化端口</span></span><br><span class="line">	GPIO_Init(GPIOF,&amp;GPIO_Initstructure);</span><br><span class="line"></span><br><span class="line">	PFout(<span class="number">9</span>)=<span class="number">1</span>;</span><br><span class="line">	PFout(<span class="number">10</span>)=<span class="number">1</span>;</span><br><span class="line">	</span><br><span class="line">	</span><br><span class="line">	<span class="comment">//中断优先级组配置：第二组</span></span><br><span class="line">	<span class="comment">//支持4个抢占优先级和4个响应优先级</span></span><br><span class="line">	<span class="comment">//数值越小，优先级越高</span></span><br><span class="line">	</span><br><span class="line">	NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);</span><br><span class="line">	</span><br><span class="line">	exti0_init();</span><br><span class="line">	exti1_init();</span><br><span class="line">	<span class="keyword">while</span>(<span class="number">1</span>)</span><br><span class="line">	&#123;</span><br><span class="line">	</span><br><span class="line"></span><br><span class="line"></span><br><span class="line">	&#125;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"></span><br><span class="line"><span class="type">void</span> <span class="title function_">EXTI0_IRQHandler</span><span class="params">(<span class="type">void</span>)</span></span><br><span class="line">&#123;</span><br><span class="line"></span><br><span class="line"><span class="comment">//	if(EXTI_GetITStatus(EXTI_Line0) != RESET)</span></span><br><span class="line">	<span class="keyword">if</span>(PEin(<span class="number">4</span>)==<span class="number">0</span>)</span><br><span class="line">	&#123;</span><br><span class="line">		<span class="comment">//点灯</span></span><br><span class="line">		PFout(<span class="number">9</span>)=<span class="number">0</span>;</span><br><span class="line">		<span class="comment">//延时</span></span><br><span class="line">		delay();</span><br><span class="line">		</span><br><span class="line">		<span class="comment">//熄灭</span></span><br><span class="line">		PFout(<span class="number">9</span>)=<span class="number">1</span>;</span><br><span class="line">		</span><br><span class="line">		<span class="comment">//清除标志位</span></span><br><span class="line">		EXTI_ClearITPendingBit(EXTI_Line0);</span><br><span class="line">	&#125;</span><br><span class="line"></span><br><span class="line"></span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="type">void</span> <span class="title function_">EXTI1_IRQHandler</span><span class="params">(<span class="type">void</span>)</span></span><br><span class="line">&#123;</span><br><span class="line"></span><br><span class="line">	<span class="keyword">if</span>(EXTI_GetITStatus(EXTI_Line1) == RESET)</span><br><span class="line">	&#123;</span><br><span class="line">		<span class="comment">//点灯</span></span><br><span class="line">		PFout(<span class="number">10</span>)=<span class="number">0</span>;</span><br><span class="line">		<span class="comment">//延时</span></span><br><span class="line">		delay();</span><br><span class="line">		</span><br><span class="line">		<span class="comment">//熄灭</span></span><br><span class="line">		PFout(<span class="number">10</span>)=<span class="number">1</span>;</span><br><span class="line">		</span><br><span class="line">		<span class="comment">//清除标志位</span></span><br><span class="line">		EXTI_ClearITPendingBit(EXTI_Line1);</span><br><span class="line">	&#125;</span><br><span class="line"></span><br><span class="line"></span><br><span class="line">&#125;</span><br><span class="line"></span><br></pre></td></tr></table></figure>
</article><div class="post-copyright"><div class="post-copyright__title"><span class="post-copyright-info"><h>外部中断</h></span></div><div class="post-copyright__type"><span class="post-copyright-info"><a href="https://certainly.gitee.io/posts/29e72e31.html">https://certainly.gitee.io/posts/29e72e31.html</a></span></div><div class="post-copyright-m"><div class="post-copyright-m-info"><div class="post-copyright-a"><h>作者</h><div class="post-copyright-cc-info"><h>Certainly</h></div></div><div class="post-copyright-c"><h>发布于</h><div class="post-copyright-cc-info"><h>2023-08-23</h></div></div><div class="post-copyright-u"><h>更新于</h><div class="post-copyright-cc-info"><h>2023-08-23</h></div></div><div class="post-copyright-c"><h>许可协议</h><div class="post-copyright-cc-info"><a class="icon" rel="noopener" target="_blank" title="Creative Commons" href="https://creativecommons.org/"><i class="fab fa-creative-commons"></i></a><a rel="noopener" target="_blank" title="CC BY-NC-SA 4.0" href="https://creativecommons.org/licenses/by-nc-sa/4.0/">CC BY-NC-SA 4.0</a></div></div></div></div></div><div class="tag_share"><div class="post-meta__tag-list"><a class="post-meta__tags" href="/tags/%E5%AD%A6%E4%B9%A0/"><div class="tags-punctuation"><svg class="faa-tada icon" style="height:1.1em;width:1.1em;fill:currentColor;position:relative;top:2px;margin-right:3px" aria-hidden="true"><use xlink:href="#icon-sekuaibiaoqian"></use></svg></div>学习</a><a class="post-meta__tags" href="/tags/%E7%AC%94%E8%AE%B0/"><div class="tags-punctuation"><svg class="faa-tada icon" style="height:1.1em;width:1.1em;fill:currentColor;position:relative;top:2px;margin-right:3px" aria-hidden="true"><use xlink:href="#icon-sekuaibiaoqian"></use></svg></div>笔记</a></div></div><link rel="stylesheet" href="/css/coin.css" media="defer" onload="this.media='all'"/><div class="post-reward"><button class="tip-button reward-button"><span class="tip-button__text">投喂作者</span><div class="coin-wrapper"><div class="coin"><div class="coin__middle"></div><div class="coin__back"></div><div class="coin__front"></div></div></div><div class="reward-main"><ul class="reward-all"><li class="reward-item"><a target="_blank"><img class="post-qr-code-img" src= "" data-lazy-src="/null" alt="微信"/></a><div class="post-qr-code-desc">微信</div></li><li class="reward-item"><a target="_blank"><img class="post-qr-code-img" src= "" data-lazy-src="/null" alt="支付宝"/></a><div class="post-qr-code-desc">支付宝</div></li></ul></div></button></div><audio id="coinAudio" src="https://npm.elemecdn.com/akilar-candyassets@1.0.36/audio/aowu.m4a"></audio><script defer="defer" src="/js/coin.js"></script><nav class="pagination-post" id="pagination"><div class="prev-post pull-left"><a href="/posts/ec298204.html"><img class="prev-cover" src= "" data-lazy-src="https://s1.vika.cn/space/2022/09/17/6627f0a573bc42fe9ce7f9cc51fefd99" onerror="onerror=null;src='/assets/r2.jpg'" alt="cover of previous post"><div class="pagination-info"><div class="label">上一篇</div><div class="prev_info">系统定时器</div></div></a></div><div class="next-post pull-right"><a href="/posts/a9da1c70.html"><img class="next-cover" src= "" data-lazy-src="https://source.fomal.cc/img/default_cover_14.webp" onerror="onerror=null;src='/assets/r2.jpg'" alt="cover of next post"><div class="pagination-info"><div class="label">下一篇</div><div class="next_info">位带操作</div></div></a></div></nav><div class="relatedPosts"><div class="headline"><i class="fas fa-thumbs-up fa-fw"></i><span>相关推荐</span></div><div class="relatedPosts-list"><div><a href="/posts/84a9a809.html" title="嵌入式day01"><img class="cover" src= "" data-lazy-src="https://s1.vika.cn/space/2022/09/17/e40d318236a04b98a7dd84f90f0f1214" alt="cover"><div class="content is-center"><div class="date"><i class="fas fa-history fa-fw"></i> 2023-11-21</div><div class="title">嵌入式day01</div></div></a></div><div><a href="/posts/1da0f9b3.html" title="嵌入式day02"><img class="cover" src= "" data-lazy-src="https://s1.vika.cn/space/2022/09/17/e40d318236a04b98a7dd84f90f0f1214" alt="cover"><div class="content is-center"><div class="date"><i class="fas fa-history fa-fw"></i> 2023-11-21</div><div class="title">嵌入式day02</div></div></a></div><div><a href="/posts/6aa7c925.html" title="嵌入式day03"><img class="cover" src= "" data-lazy-src="https://s1.vika.cn/space/2022/09/17/56e6e697b218485d9ef9c5bb4f2c57d2" alt="cover"><div class="content is-center"><div class="date"><i class="fas fa-history fa-fw"></i> 2023-11-21</div><div class="title">嵌入式day03</div></div></a></div><div><a href="/posts/f4c35c86.html" title="嵌入式day04"><img class="cover" src= "" data-lazy-src="https://source.fomal.cc/img/default_cover_14.webp" alt="cover"><div class="content is-center"><div class="date"><i class="fas fa-history fa-fw"></i> 2023-11-21</div><div class="title">嵌入式day04</div></div></a></div><div><a href="/posts/83c46c10.html" title="嵌入式day05"><img class="cover" src= "" data-lazy-src="https://source.fomal.cc/img/default_cover_14.webp" alt="cover"><div class="content is-center"><div class="date"><i class="fas fa-history fa-fw"></i> 2023-11-21</div><div class="title">嵌入式day05</div></div></a></div><div><a href="/posts/8ce33965.html" title="GPIO"><img class="cover" src= "" data-lazy-src="https://s1.vika.cn/space/2022/09/17/e40d318236a04b98a7dd84f90f0f1214" alt="cover"><div class="content is-center"><div class="date"><i class="fas fa-history fa-fw"></i> 2023-08-18</div><div class="title">GPIO</div></div></a></div></div></div><hr/><div id="post-comment"><div class="comment-head"><div class="comment-headline"><i class="fas fa-comments fa-fw"></i><span> 评论</span></div></div><div class="comment-wrap"><div><div id="twikoo-wrap"></div></div></div></div></div><div class="aside-content" id="aside-content"><div class="sticky_layout"><div class="card-widget" id="card-toc"><div class="item-headline"><svg class="meta_icon" style="width:22px;height:22px;position:relative;top:5px"><use xlink:href="#icon-mulu1"></use></svg><span style="font-weight:bold">目录</span><span class="toc-percentage"></span></div><div class="toc-content"><ol class="toc"><li class="toc-item toc-level-3"><a class="toc-link" href="#%E4%B8%80%E3%80%81%E5%BC%82%E5%B8%B8%E4%B8%8E%E4%B8%AD%E6%96%AD"><span class="toc-text">一、异常与中断</span></a><ol class="toc-child"><li class="toc-item toc-level-4"><a class="toc-link" href="#%EF%BC%88%E4%B8%80%EF%BC%89%E6%A6%82%E8%BF%B0"><span class="toc-text">（一）概述</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#%EF%BC%88%E4%BA%8C%EF%BC%89%E5%BC%82%E5%B8%B8%E7%B1%BB%E5%9E%8B"><span class="toc-text">（二）异常类型</span></a><ol class="toc-child"><li class="toc-item toc-level-5"><a class="toc-link" href="#1-%E7%B3%BB%E7%BB%9F%E5%BC%82%E5%B8%B8"><span class="toc-text">1.系统异常</span></a></li><li class="toc-item toc-level-5"><a class="toc-link" href="#2-%E4%B8%AD%E6%96%AD"><span class="toc-text">2.中断</span></a></li></ol></li><li class="toc-item toc-level-4"><a class="toc-link" href="#%EF%BC%88%E4%B8%89%EF%BC%89%E4%B8%AD%E6%96%AD%E6%8E%A7%E5%88%B6"><span class="toc-text">（三）中断控制</span></a><ol class="toc-child"><li class="toc-item toc-level-5"><a class="toc-link" href="#3-%E5%90%91%E9%87%8F%E8%A1%A8%EF%BC%88Vector-table%EF%BC%89"><span class="toc-text">3.向量表（Vector table）</span></a></li></ol></li></ol></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E4%BA%8C%E3%80%81ARM-Cortex-M4-%E7%9A%84%E4%B8%AD%E6%96%AD%E4%BD%93%E7%B3%BB"><span class="toc-text">二、ARM Cortex-M4 的中断体系</span></a><ol class="toc-child"><li class="toc-item toc-level-4"><a class="toc-link" href="#1%E3%80%81%E5%AE%9A%E4%B9%89"><span class="toc-text">1、定义</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#2"><span class="toc-text">2.</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#%E4%BA%8C%E3%80%81%E4%BB%A3%E7%A0%81%E6%80%9D%E8%B7%AF"><span class="toc-text">二、代码思路</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#%E4%B8%89%E3%80%81%E5%87%BD%E6%95%B0%E6%8E%A5%E5%8F%A3"><span class="toc-text">三、函数接口</span></a><ol class="toc-child"><li class="toc-item toc-level-5"><a class="toc-link" href="#1-%E4%B8%BA%E5%BC%95%E8%84%9A%E9%80%89%E6%8B%A9%E4%BD%BF%E7%94%A8%E5%93%AA%E4%B8%AA%E4%B8%AD%E6%96%AD"><span class="toc-text">1.为引脚选择使用哪个中断</span></a></li><li class="toc-item toc-level-5"><a class="toc-link" href="#2-%E9%85%8D%E7%BD%AE%E5%A4%96%E9%83%A8%E4%B8%AD%E6%96%AD"><span class="toc-text">2.配置外部中断</span></a></li><li class="toc-item toc-level-5"><a class="toc-link" href="#3-%E4%B8%AD%E6%96%AD%E4%BC%98%E5%85%88%E7%BA%A7%E9%85%8D%E7%BD%AE"><span class="toc-text">3.中断优先级配置</span></a></li><li class="toc-item toc-level-5"><a class="toc-link" href="#4-%E8%8E%B7%E5%8F%96%E5%A4%96%E9%83%A8%E4%B8%AD%E6%96%AD%E7%8A%B6%E6%80%81"><span class="toc-text">4.获取外部中断状态</span></a></li><li class="toc-item toc-level-5"><a class="toc-link" href="#5-%E6%B8%85%E7%A9%BA%E5%A4%96%E9%83%A8%E4%B8%AD%E6%96%AD%E6%A0%87%E5%BF%97%E4%BD%8D"><span class="toc-text">5.清空外部中断标志位</span></a></li></ol></li></ol></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E4%B8%89%E3%80%81%E4%B8%AD%E6%96%AD%E4%BC%98%E5%85%88%E7%BA%A7"><span class="toc-text">三、中断优先级</span></a><ol class="toc-child"><li class="toc-item toc-level-4"><a class="toc-link" href="#1-%E6%A6%82%E8%BF%B0"><span class="toc-text">1.概述</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#2-%E6%8A%A2%E5%8D%A0%E4%BC%98%E5%85%88%E7%BA%A7%E4%B8%8E%E5%93%8D%E5%BA%94%E4%BC%98%E5%85%88%E7%BA%A7%E5%8C%BA%E5%88%AB"><span class="toc-text">2.抢占优先级与响应优先级区别</span></a><ol class="toc-child"><li class="toc-item toc-level-5"><a class="toc-link" href="#1-%E9%AB%98%E6%8A%A2%E5%8D%A0%E4%BC%98%E5%85%88%E7%BA%A7%E6%98%AF%E5%8F%AF%E4%BB%A5%E6%89%93%E6%96%AD%E6%AD%A3%E5%9C%A8%E8%BF%9B%E8%A1%8C%E7%9A%84%E4%BD%8E%E6%8A%A2%E5%8D%A0%E4%BC%98%E5%85%88%E7%BA%A7%E7%9A%84%E4%B8%AD%E6%96%AD%E3%80%82%E6%8A%A2%E5%8D%A0%E4%BC%98%E5%85%88%E7%BA%A7%E8%8B%A5%E7%9B%B8%E5%90%8C%EF%BC%8C%E5%88%99%E4%B8%8D%E4%BC%9A%E5%87%BA%E7%8E%B0%E6%8A%A2%E5%8D%A0%E7%9A%84%E8%BF%87%E7%A8%8B%E3%80%82"><span class="toc-text">1)高抢占优先级是可以打断正在进行的低抢占优先级的中断。抢占优先级若相同，则不会出现抢占的过程。</span></a></li><li class="toc-item toc-level-5"><a class="toc-link" href="#2-%E6%8A%A2%E5%8D%A0%E4%BC%98%E5%85%88%E7%BA%A7%E7%9B%B8%E5%90%8C%E7%9A%84%E4%B8%AD%E6%96%AD%EF%BC%8C%E9%AB%98%E5%93%8D%E5%BA%94%E4%BC%98%E5%85%88%E7%BA%A7%E4%B8%8D%E5%8F%AF%E4%BB%A5%E6%89%93%E6%96%AD%E4%BD%8E%E5%93%8D%E5%BA%94%E4%BC%98%E5%85%88%E7%BA%A7%E7%9A%84%E4%B8%AD%E6%96%AD%E3%80%82"><span class="toc-text">2)抢占优先级相同的中断，高响应优先级不可以打断低响应优先级的中断。</span></a></li><li class="toc-item toc-level-5"><a class="toc-link" href="#3-%E6%8A%A2%E5%8D%A0%E4%BC%98%E5%85%88%E7%BA%A7%E7%9B%B8%E5%90%8C%E7%9A%84%E4%B8%AD%E6%96%AD%EF%BC%8C%E5%BD%93%E4%B8%A4%E4%B8%AA%E4%B8%AD%E6%96%AD%E5%90%8C%E6%97%B6%E5%8F%91%E7%94%9F%E7%9A%84%E6%83%85%E5%86%B5%E4%B8%8B%EF%BC%8C%E5%93%AA%E4%B8%AA%E5%93%8D%E5%BA%94%E4%BC%98%E5%85%88%E7%BA%A7%E9%AB%98%EF%BC%8C%E5%93%AA%E4%B8%AA%E5%85%88%E6%89%A7%E8%A1%8C%E3%80%82"><span class="toc-text">3)抢占优先级相同的中断，当两个中断同时发生的情况下，哪个响应优先级高，哪个先执行。</span></a></li><li class="toc-item toc-level-5"><a class="toc-link" href="#4-%E6%8A%A2%E5%8D%A0%E4%BC%98%E5%85%88%E7%BA%A7%E7%9B%B8%E5%90%8C%E4%B8%94%E5%93%8D%E5%BA%94%E4%BC%98%E5%85%88%E7%BA%A7%E7%9B%B8%E5%90%8C%E7%9A%84%E4%B8%AD%E6%96%AD%EF%BC%8C%E5%81%87%E5%A6%82%E5%90%8C%E6%97%B6%E5%8F%91%E7%94%9F%EF%BC%8C%E4%BC%9A%E6%8C%89%E7%85%A7%E7%A1%AC%E4%BB%B6%E5%86%85%E9%83%A8%E5%9B%BA%E5%AE%9A%E7%9A%84%E4%BC%98%E5%85%88%E7%BA%A7%E6%89%A7%E8%A1%8C%EF%BC%8C%E5%A6%82%E4%B8%8B%E5%9B%BE%E3%80%82"><span class="toc-text">4)抢占优先级相同且响应优先级相同的中断，假如同时发生，会按照硬件内部固定的优先级执行，如下图。</span></a></li><li class="toc-item toc-level-5"><a class="toc-link" href="#5-%E6%97%A0%E8%AE%BA%E6%98%AF%E6%8A%A2%E5%8D%A0%E4%BC%98%E5%85%88%E7%BA%A7%E8%BF%98%E6%98%AF%E5%93%8D%E5%BA%94%E4%BC%98%E5%85%88%E7%BA%A7%EF%BC%8C%E4%BC%98%E5%85%88%E7%BA%A7%E6%95%B0%E5%80%BC%E8%B6%8A%E5%B0%8F%EF%BC%8C%E5%B0%B1%E4%BB%A3%E8%A1%A8%E4%BC%98%E5%85%88%E7%BA%A7%E8%B6%8A%E9%AB%98%E3%80%82"><span class="toc-text">5)无论是抢占优先级还是响应优先级，优先级数值越小，就代表优先级越高。</span></a></li></ol></li></ol></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E5%9B%9B%E3%80%81%E4%B8%AD%E6%96%AD%E6%9C%8D%E5%8A%A1%E5%87%BD%E6%95%B0"><span class="toc-text">四、中断服务函数</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E4%BA%94%E3%80%81%E5%BA%94%E7%94%A8%E5%9C%BA%E6%99%AF"><span class="toc-text">五、应用场景</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E6%93%8D%E4%BD%9C%E6%B5%81%E7%A8%8B"><span class="toc-text">操作流程</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E7%BB%83%E4%B9%A0"><span class="toc-text">练习</span></a><ol class="toc-child"><li class="toc-item toc-level-4"><a class="toc-link" href="#%E3%80%90%E4%B8%AD%E6%96%AD%E7%BB%83%E4%B9%A0%E3%80%91"><span class="toc-text">【中断练习】</span></a></li></ol></li></ol></div></div></div></div></main><footer id="footer" style="background-color: transparent;"><div id="footer-wrap"><div id="ft"><div class="ft-item-1"><div class="t-top"><div class="t-t-l"><p class="ft-t t-l-t">格言🧬</p><div class="bg-ad"><div>再看看那个光点，它就在这里，这是家园，这是我们 —— 你所爱的每一个人，你认识的一个人，你听说过的每一个人，曾经有过的每一个人，都在它上面度过他们的一生✨</div><div class="btn-xz-box"><a class="btn-xz" target="_blank" rel="noopener" href="https://stellarium.org/">点击开启星辰之旅</a></div></div></div><div class="t-t-r"><p class="ft-t t-l-t">猜你想看💡</p><ul class="ft-links"><li><a href="/posts/eec9786.html">魔改指南</a><a href="/box/nav/">网址导航</a></li><li><a href="/social/link/">我的朋友</a><a href="/comments/">留点什么</a></li><li><a href="/personal/about/">关于作者</a><a href="/archives/">文章归档</a></li><li><a href="/categories/">文章分类</a><a href="/tags/">文章标签</a></li><li><a href="/box/Gallery/">我的画廊</a><a href="/personal/bb/">我的唠叨</a></li><li><a href="/site/time/">建设进程</a><a href="/site/census/">网站统计</a></li></ul></div></div></div><div class="ft-item-2"><p class="ft-t">推荐友链⌛</p><div class="ft-img-group"><div class="img-group-item"><a target="_blank" rel="noopener" href="https://www.fomal.cc/" title="Fomalhaut🥝"><img src= "" data-lazy-src="https://lskypro.acozycotage.net/LightPicture/2022/12/60e5d4e39da7c077.webp" alt=""/></a></div><div class="img-group-item"><a href="javascript:void(0)" title="广告位招租"><img src= "" data-lazy-src="https://lskypro.acozycotage.net/LightPicture/2022/12/65307a5828af6790.webp" alt=""/></a></div><div class="img-group-item"><a href="javascript:void(0)" title="广告位招租"><img src= "" data-lazy-src="https://lskypro.acozycotage.net/LightPicture/2022/12/65307a5828af6790.webp" alt=""/></a></div><div class="img-group-item"><a href="javascript:void(0)" title="广告位招租"><img src= "" data-lazy-src="https://lskypro.acozycotage.net/LightPicture/2022/12/65307a5828af6790.webp" alt=""/></a></div><div class="img-group-item"><a href="javascript:void(0)" title="广告位招租"><img src= "" data-lazy-src="https://lskypro.acozycotage.net/LightPicture/2022/12/65307a5828af6790.webp" alt=""/></a></div><div class="img-group-item"><a href="javascript:void(0)" title="广告位招租"><img src= "" data-lazy-src="https://lskypro.acozycotage.net/LightPicture/2022/12/65307a5828af6790.webp" alt=""/></a></div><div class="img-group-item"><a href="javascript:void(0)" title="广告位招租"><img src= "" data-lazy-src="https://lskypro.acozycotage.net/LightPicture/2022/12/65307a5828af6790.webp" alt=""/></a></div><div class="img-group-item"><a href="javascript:void(0)" title="广告位招租"><img src= "" data-lazy-src="https://lskypro.acozycotage.net/LightPicture/2022/12/65307a5828af6790.webp" alt=""/></a></div></div></div></div><div class="copyright"><span><b>&copy;2022-2023</b></span><span><b>&nbsp;&nbsp;By Certainly</b></span></div><div id="workboard"></div><p id="ghbdages"><a class="github-badge" target="_blank" href="https://hexo.io/" style="margin-inline:5px" title="博客框架为Hexo_v6.3.0"><img src= "" data-lazy-src="https://sourcebucket.s3.ladydaily.com/badge/Frame-Hexo-blue.svg" alt=""/></a><a class="github-badge" target="_blank" href="https://butterfly.js.org/" style="margin-inline:5px" title="主题版本Butterfly_v4.3.1"><img src= "" data-lazy-src="https://sourcebucket.s3.ladydaily.com/badge/Theme-Butterfly-6513df.svg" alt=""/></a><a class="github-badge" target="_blank" href="https://vercel.com/" style="margin-inline:5px" title="本站采用多线部署，主线路托管于Vercel"><img src= "" data-lazy-src="https://sourcebucket.s3.ladydaily.com/badge/Hosted-Vercel-brightgreen.svg" alt=""/></a><a class="github-badge" target="_blank" href="https://user.51.la/" style="margin-inline:5px" title="本站数据分析得益于51la技术支持"><img src= "" data-lazy-src="https://sourcebucket.s3.ladydaily.com/badge/Analytics-51la-3db1eb.svg" alt=""/></a><a class="github-badge" target="_blank" href="https://icp.gov.moe/?keyword=20226665" style="margin-inline:5px" title="本站已加入萌ICP豪华套餐，萌ICP备20226665号"><img src= "" data-lazy-src="https://sourcebucket.s3.ladydaily.com/badge/萌ICP备-20226665-fe1384.svg" alt=""/></a><a class="github-badge" target="_blank" href="https://bitiful.dogecast.com/buckets" style="margin-inline:5px" title="本网站经Service Worker分流至缤纷云对象存储"><img src= "" data-lazy-src=" https://sourcebucket.s3.ladydaily.com/badge/Bucket-缤纷云-9c62da.svg" alt=""/></a><a class="github-badge" target="_blank" href="https://www.netdun.net/" style="margin-inline:5px" title="本站使用网盾星球提供CDN加速与防护"><img src= "" data-lazy-src="https://sourcebucket.s3.ladydaily.com/badge/CDN-网盾星球-fff2cc.svg" alt=""/></a><a class="github-badge" target="_blank" href="https://github.com/" style="margin-inline:5px" title="本网站源码由Github提供存储仓库"><img src= "" data-lazy-src=" https://sourcebucket.s3.ladydaily.com/badge/Source-Github-d021d6.svg" alt=""/></a></p></div></footer></div><div id="rightside"><div id="rightside-config-hide"><button id="readmode" type="button" title="阅读模式"><i class="fas fa-book-open"></i></button><a class="icon-V hidden" onclick="switchNightMode()" title="浅色和深色模式转换"><svg width="25" height="25" viewBox="0 0 1024 1024"><use id="modeicon" xlink:href="#icon-moon"></use></svg></a><button id="hide-aside-btn" type="button" title="单栏和双栏切换"><i class="fas fa-arrows-alt-h"></i></button><button class="share" type="button" title="右键模式" onclick="changeMouseMode()"><i class="fas fa-mouse"></i></button></div><div id="rightside-config-show"><button id="rightside_config" type="button" title="设置"><i class="fas fa-cog right_side"></i></button><button class="close" id="mobile-toc-button" type="button" title="目录"><i class="fas fa-list-ul"></i></button><button class="share" type="button" title="分享链接" onclick="share()"><i class="fas fa-share-nodes"></i></button><a id="to_comment" href="#post-comment" title="直达评论"><i class="fas fa-comments"></i></a><button id="go-up" type="button" title="回到顶部"><i class="fas fa-arrow-up"></i><span id="percent">0<span>%</span></span></button><button id="go-down" type="button" title="直达底部" onclick="btf.scrollToDest(document.body.scrollHeight, 500)"><i class="fas fa-arrow-down"></i></button></div></div><div id="local-search"><div class="search-dialog"><nav class="search-nav"><span class="search-dialog-title">搜索</span><span id="loading-status"></span><button class="search-close-button"><i class="fas fa-times"></i></button></nav><div class="is-center" id="loading-database"><i class="fas fa-spinner fa-pulse"></i><span>  数据库加载中</span></div><div class="search-wrap"><div id="local-search-input"><div class="local-search-box"><input class="local-search-box--input" placeholder="搜索文章" type="text"/></div></div><hr/><div id="local-search-results"></div></div></div><div id="search-mask"></div></div><div class="js-pjax" id="rightMenu"><div class="rightMenu-group rightMenu-small"><a class="rightMenu-item" href="javascript:window.history.back();"><i class="fa fa-arrow-left"></i></a><a class="rightMenu-item" href="javascript:window.history.forward();"><i class="fa fa-arrow-right"></i></a><a class="rightMenu-item" href="javascript:window.location.reload();"><i class="fa fa-refresh"></i></a><a class="rightMenu-item" href="javascript:rmf.scrollToTop();"><i class="fa fa-arrow-up"></i></a></div><div class="rightMenu-group rightMenu-line hide" id="menu-text"><a class="rightMenu-item" href="javascript:rmf.copySelect();"><i class="fa fa-copy"></i><span>复制</span></a><a class="rightMenu-item" href="javascript:window.open(&quot;https://www.baidu.com/s?wd=&quot;+window.getSelection().toString());window.location.reload();"><i class="fa fa-search"></i><span>百度搜索</span></a></div><div class="rightMenu-group rightMenu-line hide" id="menu-too"><a class="rightMenu-item" href="javascript:window.open(window.getSelection().toString());window.location.reload();"><i class="fa fa-link"></i><span>转到链接</span></a></div><div class="rightMenu-group rightMenu-line hide" id="menu-paste"><a class="rightMenu-item" href="javascript:rmf.paste()"><i class="fa fa-copy"></i><span>粘贴</span></a></div><div class="rightMenu-group rightMenu-line hide" id="menu-post"><a class="rightMenu-item" href="#post-comment"><i class="fas fa-comment"></i><span>空降评论</span></a><a class="rightMenu-item" href="javascript:rmf.copyWordsLink()"><i class="fa fa-link"></i><span>复制本文地址</span></a></div><div class="rightMenu-group rightMenu-line hide" id="menu-to"><a class="rightMenu-item" href="javascript:rmf.openWithNewTab()"><i class="fa fa-window-restore"></i><span>新窗口打开</span></a><a class="rightMenu-item" id="menu-too" href="javascript:rmf.open()"><i class="fa fa-link"></i><span>转到链接</span></a><a class="rightMenu-item" href="javascript:rmf.copyLink()"><i class="fa fa-copy"></i><span>复制链接</span></a></div><div class="rightMenu-group rightMenu-line hide" id="menu-img"><a class="rightMenu-item" href="javascript:rmf.saveAs()"><i class="fa fa-download"></i><span>保存图片</span></a><a class="rightMenu-item" href="javascript:rmf.openWithNewTab()"><i class="fa fa-window-restore"></i><span>在新窗口打开</span></a><a class="rightMenu-item" href="javascript:rmf.copyLink()"><i class="fa fa-copy"></i><span>复制图片链接</span></a></div><div class="rightMenu-group rightMenu-line"><a class="rightMenu-item" href="javascript:randomPost()"><i class="fa fa-paper-plane"></i><span>随便逛逛</span></a><a class="rightMenu-item" href="javascript:switchNightMode();"><i class="fa fa-moon"></i><span>昼夜切换</span></a><a class="rightMenu-item" href="/personal/about/"><i class="fa fa-info-circle"></i><span>关于博客</span></a><a class="rightMenu-item" href="javascript:toggleWinbox();"><i class="fas fa-cog"></i><span>美化设置</span></a><a class="rightMenu-item" href="javascript:rmf.fullScreen();"><i class="fas fa-expand"></i><span>切换全屏</span></a><a class="rightMenu-item" href="javascript:window.print();"><i class="fa-solid fa-print"></i><span>打印页面</span></a></div></div><div><script src="/js/utils.js"></script><script src="/js/main.js"></script><script src="https://cdn.staticfile.org/fancyapps-ui/4.0.31/fancybox.umd.min.js"></script><script src="https://lf3-cdn-tos.bytecdntp.com/cdn/expire-1-M/instant.page/5.1.0/instantpage.min.js" type="module"></script><script src="https://lf3-cdn-tos.bytecdntp.com/cdn/expire-1-M/vanilla-lazyload/17.3.1/lazyload.iife.min.js"></script><script src="/js/search/local-search.js"></script><script async="async">var preloader = {
  endLoading: () => {
    document.body.style.overflow = 'auto';
    document.getElementById('loading-box').classList.add("loaded")
  },
  initLoading: () => {
    document.body.style.overflow = '';
    document.getElementById('loading-box').classList.remove("loaded")

  }
}
window.addEventListener('load',preloader.endLoading())
setTimeout(function(){preloader.endLoading();}, 5000);
document.getElementById('loading-box').addEventListener('click',()=> {preloader.endLoading()})</script><div class="js-pjax"><script>if (!window.MathJax) {
  window.MathJax = {
    tex: {
      inlineMath: [ ['$','$'], ["\\(","\\)"]],
      tags: 'ams'
    },
    chtml: {
      scale: 1.2
    },
    options: {
      renderActions: {
        findScript: [10, doc => {
          for (const node of document.querySelectorAll('script[type^="math/tex"]')) {
            const display = !!node.type.match(/; *mode=display/)
            const math = new doc.options.MathItem(node.textContent, doc.inputJax[0], display)
            const text = document.createTextNode('')
            node.parentNode.replaceChild(text, node)
            math.start = {node: text, delim: '', n: 0}
            math.end = {node: text, delim: '', n: 0}
            doc.math.push(math)
          }
        }, ''],
        insertScript: [200, () => {
          document.querySelectorAll('mjx-container:not\([display]\)').forEach(node => {
            const target = node.parentNode
            if (target.nodeName.toLowerCase() === 'li') {
              target.parentNode.classList.add('has-jax')
            } else {
              target.classList.add('has-jax')
            }
          });
        }, '', false]
      }
    }
  }
  
  const script = document.createElement('script')
  script.src = 'https://cdnjs.cloudflare.com/ajax/libs/mathjax/3.2.2/es5/tex-mml-chtml.min.js'
  script.id = 'MathJax-script'
  script.async = true
  document.head.appendChild(script)
} else {
  MathJax.startup.document.state(0)
  MathJax.texReset()
  MathJax.typeset()
}</script><script>(()=>{
  const init = () => {
    twikoo.init(Object.assign({
      el: '#twikoo-wrap',
      envId: '',
      region: '',
      onCommentLoaded: function () {
        btf.loadLightbox(document.querySelectorAll('#twikoo .tk-content img:not(.tk-owo-emotion)'))
      }
    }, null))
  }

  const getCount = () => {
    const countELement = document.getElementById('twikoo-count')
    if(!countELement) return
    twikoo.getCommentsCount({
      envId: '',
      region: '',
      urls: [window.location.pathname],
      includeReply: false
    }).then(function (res) {
      countELement.innerText = res[0].count
    }).catch(function (err) {
      console.error(err);
    });
  }

  const runFn = () => {
    init()
    
  }

  const loadTwikoo = () => {
    if (typeof twikoo === 'object') {
      setTimeout(runFn,0)
      return
    } 
    getScript('https://cdn.staticfile.org/twikoo/1.6.8/twikoo.all.min.js').then(runFn)
  }

  if ('Twikoo' === 'Twikoo' || !true) {
    if (true) btf.loadComment(document.getElementById('twikoo-wrap'), loadTwikoo)
    else loadTwikoo()
  } else {
    window.loadOtherComment = () => {
      loadTwikoo()
    }
  }
})()</script></div><script src="https://cdn.staticfile.org/jquery/3.6.3/jquery.min.js"></script><script async src="https://cdn1.tianli0.top/npm/vue@2.6.14/dist/vue.min.js"></script><script async src="https://cdn1.tianli0.top/npm/element-ui@2.15.6/lib/index.js"></script><script async src="https://cdn.bootcdn.net/ajax/libs/clipboard.js/2.0.11/clipboard.min.js"></script><script defer type="text/javascript" src="https://cdn1.tianli0.top/npm/sweetalert2@8.19.0/dist/sweetalert2.all.js"></script><script async src="//npm.elemecdn.com/pace-js@1.2.4/pace.min.js"></script><script defer src="https://cdn1.tianli0.top/gh/nextapps-de/winbox/dist/winbox.bundle.min.js"></script><script async src="//at.alicdn.com/t/c/font_3586335_hsivh70x0fm.js"></script><script async src="//at.alicdn.com/t/c/font_3636804_gr02jmjr3y9.js"></script><script async src="//at.alicdn.com/t/c/font_3612150_kfv55xn3u2g.js"></script><script async src="https://cdn.wpon.cn/2022-sucai/Gold-ingot.js"></script><canvas id="universe"></canvas><canvas id="snow"></canvas><script defer src="/js/fomal.js"></script><link rel="stylesheet" href="https://lf6-cdn-tos.bytecdntp.com/cdn/expire-1-M/aplayer/1.10.1/APlayer.min.css" media="print" onload="this.media='all'"><script src="https://lf6-cdn-tos.bytecdntp.com/cdn/expire-1-M/aplayer/1.10.1/APlayer.min.js"></script><script src="https://cdn1.tianli0.top/npm/js-heo@1.0.12/metingjs/Meting.min.js"></script><script src="https://lib.baomitu.com/pjax/0.2.8/pjax.min.js"></script><script>let pjaxSelectors = ["head > title","#config-diff","#body-wrap","#rightside-config-hide","#rightside-config-show","#web_bg",".js-pjax","#bibi","body > title","#app","#tag-echarts","#posts-echart","#categories-echarts"]

var pjax = new Pjax({
  elements: 'a:not([target="_blank"])',
  selectors: pjaxSelectors,
  cacheBust: false,
  analytics: false,
  scrollRestoration: false
})

document.addEventListener('pjax:send', function () {

  // removeEventListener scroll 
  window.tocScrollFn && window.removeEventListener('scroll', window.tocScrollFn)
  window.scrollCollect && window.removeEventListener('scroll', scrollCollect)

  typeof preloader === 'object' && preloader.initLoading()
  document.getElementById('rightside').style.cssText = "opacity: ''; transform: ''"
  
  if (window.aplayers) {
    for (let i = 0; i < window.aplayers.length; i++) {
      if (!window.aplayers[i].options.fixed) {
        window.aplayers[i].destroy()
      }
    }
  }

  typeof typed === 'object' && typed.destroy()

  //reset readmode
  const $bodyClassList = document.body.classList
  $bodyClassList.contains('read-mode') && $bodyClassList.remove('read-mode')

  typeof disqusjs === 'object' && disqusjs.destroy()
})

document.addEventListener('pjax:complete', function () {
  window.refreshFn()

  document.querySelectorAll('script[data-pjax]').forEach(item => {
    const newScript = document.createElement('script')
    const content = item.text || item.textContent || item.innerHTML || ""
    Array.from(item.attributes).forEach(attr => newScript.setAttribute(attr.name, attr.value))
    newScript.appendChild(document.createTextNode(content))
    item.parentNode.replaceChild(newScript, item)
  })

  GLOBAL_CONFIG.islazyload && window.lazyLoadInstance.update()

  typeof chatBtnFn === 'function' && chatBtnFn()
  typeof panguInit === 'function' && panguInit()

  // google analytics
  typeof gtag === 'function' && gtag('config', '', {'page_path': window.location.pathname});

  // baidu analytics
  typeof _hmt === 'object' && _hmt.push(['_trackPageview',window.location.pathname]);

  typeof loadMeting === 'function' && document.getElementsByClassName('aplayer').length && loadMeting()

  // prismjs
  typeof Prism === 'object' && Prism.highlightAll()

  typeof preloader === 'object' && preloader.endLoading()
})

document.addEventListener('pjax:error', (e) => {
  if (e.request.status === 404) {
    pjax.loadUrl('/404.html')
  }
})</script><script async data-pjax src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script></div><!-- hexo injector body_end start --> <script data-pjax>if(document.getElementById('recent-posts') && (location.pathname ==='/'|| '/' ==='all')){
    var parent = document.getElementById('recent-posts');
    var child = '<div class="recent-post-item" style="width:100%;height: auto"><div id="catalog_magnet"><div class="magnet_item"><a class="magnet_link" href="https://certainly.gitee.io/categories/演示/"><div class="magnet_link_context" style=""><span style="font-weight:500;flex:1">🍥 演示笔记 (1)</span><span style="padding:0px 4px;border-radius: 8px;"><i class="fas fa-arrow-circle-right"></i></span></div></a></div><div class="magnet_item"><a class="magnet_link" href="https://certainly.gitee.io/categories/嵌入式/"><div class="magnet_link_context" style=""><span style="font-weight:500;flex:1">💻 嵌入式笔记 (14)</span><span style="padding:0px 4px;border-radius: 8px;"><i class="fas fa-arrow-circle-right"></i></span></div></a></div><div class="magnet_item" style="visibility: hidden"></div><a class="magnet_link_more"  href="https://certainly.gitee.io/categories/" style="flex:1;text-align: center;margin-bottom: 10px;">查看更多...</a></div></div>';
    console.log('已挂载magnet')
    parent.insertAdjacentHTML("afterbegin",child)}
     </script><style>#catalog_magnet{flex-wrap: wrap;display: flex;width:100%;justify-content:space-between;padding: 10px 10px 0 10px;align-content: flex-start;}.magnet_item{flex-basis: calc(33.333333333333336% - 5px);background: #e9e9e9;margin-bottom: 10px;border-radius: 8px;transition: all 0.2s ease-in-out;}.magnet_item:hover{background: var(--text-bg-hover)}.magnet_link_more{color:#555}.magnet_link{color:black}.magnet_link:hover{color:white}@media screen and (max-width: 600px) {.magnet_item {flex-basis: 100%;}}.magnet_link_context{display:flex;padding: 10px;font-size:16px;transition: all 0.2s ease-in-out;}.magnet_link_context:hover{padding: 10px 20px;}</style>
    <style></style><script data-pjax>
  function butterfly_swiper_injector_config(){
    var parent_div_git = document.getElementById('recent-posts');
    var item_html = '<div class="recent-post-item" style="height: auto;width: 100%"><div class="blog-slider swiper-container-fade swiper-container-horizontal" id="swiper_container"><div class="blog-slider__wrp swiper-wrapper" style="transition-duration: 0ms;"><div class="blog-slider__item swiper-slide" style="width: 750px; opacity: 1; transform: translate3d(0px, 0px, 0px); transition-duration: 0ms;"><a class="blog-slider__img" onclick="pjax.loadUrl(&quot;posts/2013454d.html&quot;);" href="javascript:void(0);" alt=""><img width="48" height="48" src= "" data-lazy-src="https://source.fomal.cc/img/default_cover_14.webp" alt="" onerror="this.src=https://unpkg.zhimg.com/akilar-candyassets/image/loading.gif; this.onerror = null;"/></a><div class="blog-slider__content"><span class="blog-slider__code">2022-08-09</span><a class="blog-slider__title" onclick="pjax.loadUrl(&quot;posts/2013454d.html&quot;);" href="javascript:void(0);" alt="">Markdown语法与外挂标签写法汇总</a><div class="blog-slider__text">🥧本文汇总Markdown格式以及外挂标签在网页端的渲染效果，可作为文档进行查询</div><a class="blog-slider__button" onclick="pjax.loadUrl(&quot;posts/2013454d.html&quot;);" href="javascript:void(0);" alt="">详情       </a></div></div><div class="blog-slider__item swiper-slide" style="width: 750px; opacity: 1; transform: translate3d(0px, 0px, 0px); transition-duration: 0ms;"><a class="blog-slider__img" onclick="pjax.loadUrl(&quot;posts/3dd6bae0.html&quot;);" href="javascript:void(0);" alt=""><img width="48" height="48" src= "" data-lazy-src="https://s1.vika.cn/space/2022/09/17/e40d318236a04b98a7dd84f90f0f1214" alt="" onerror="this.src=https://unpkg.zhimg.com/akilar-candyassets/image/loading.gif; this.onerror = null;"/></a><div class="blog-slider__content"><span class="blog-slider__code">2023-03-19</span><a class="blog-slider__title" onclick="pjax.loadUrl(&quot;posts/3dd6bae0.html&quot;);" href="javascript:void(0);" alt="">Hexo学习-1</a><div class="blog-slider__text">Hexo学习笔记1，Hexo文章编辑。</div><a class="blog-slider__button" onclick="pjax.loadUrl(&quot;posts/3dd6bae0.html&quot;);" href="javascript:void(0);" alt="">详情       </a></div></div></div><div class="blog-slider__pagination swiper-pagination-clickable swiper-pagination-bullets"></div></div></div>';
    console.log('已挂载butterfly_swiper')
    parent_div_git.insertAdjacentHTML("afterbegin",item_html)
    }
  var elist = 'undefined'.split(',');
  var cpage = location.pathname;
  var epage = '/';
  var flag = 0;

  for (var i=0;i<elist.length;i++){
    if (cpage.includes(elist[i])){
      flag++;
    }
  }

  if ((epage ==='all')&&(flag == 0)){
    butterfly_swiper_injector_config();
  }
  else if (epage === cpage){
    butterfly_swiper_injector_config();
  }
  </script><script defer src="https://npm.elemecdn.com/hexo-butterfly-swiper/lib/swiper.min.js"></script><script defer data-pjax src="https://npm.elemecdn.com/hexo-butterfly-swiper/lib/swiper_init.js"></script><div class="js-pjax"><script async="async">var arr = document.getElementsByClassName('recent-post-item');
for(var i = 0;i<arr.length;i++){
    arr[i].classList.add('wow');
    arr[i].classList.add('animate__zoomIn');
    arr[i].setAttribute('data-wow-duration', '2s');
    arr[i].setAttribute('data-wow-delay', '200ms');
    arr[i].setAttribute('data-wow-offset', '30');
    arr[i].setAttribute('data-wow-iteration', '1');
  }</script><script async="async">var arr = document.getElementsByClassName('card-widget');
for(var i = 0;i<arr.length;i++){
    arr[i].classList.add('wow');
    arr[i].classList.add('animate__zoomIn');
    arr[i].setAttribute('data-wow-duration', '2s');
    arr[i].setAttribute('data-wow-delay', '200ms');
    arr[i].setAttribute('data-wow-offset', '30');
    arr[i].setAttribute('data-wow-iteration', '1');
  }</script></div><script defer src="https://npm.elemecdn.com/hexo-butterfly-wowjs/lib/wow.min.js"></script><script defer src="https://npm.elemecdn.com/hexo-butterfly-wowjs/lib/wow_init.js"></script><script data-pjax src="https://npm.elemecdn.com/hexo-filter-gitcalendar/lib/gitcalendar.js"></script><script data-pjax>
  function gitcalendar_injector_config(){
      var parent_div_git = document.getElementById('gitZone');
      var item_html = '<div class="recent-post-item" id="gitcalendarBar" style="width:100%;height:auto;padding:10px;"><style>#git_container{min-height: 320px}@media screen and (max-width:650px) {#git_container{min-height: 0px}}</style><div id="git_loading" style="width:10%;height:100%;margin:0 auto;display: block;"><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 50 50" style="enable-background:new 0 0 50 50" xml:space="preserve"><path fill="#d0d0d0" d="M25.251,6.461c-10.318,0-18.683,8.365-18.683,18.683h4.068c0-8.071,6.543-14.615,14.615-14.615V6.461z" transform="rotate(275.098 25 25)"><animatetransform attributeType="xml" attributeName="transform" type="rotate" from="0 25 25" to="360 25 25" dur="0.6s" repeatCount="indefinite"></animatetransform></path></svg><style>#git_container{display: none;}</style></div><div id="git_container"></div></div>';
      parent_div_git.insertAdjacentHTML("afterbegin",item_html)
      console.log('已挂载gitcalendar')
      }

    if( document.getElementById('gitZone') && (location.pathname ==='/site/census/'|| '/site/census/' ==='all')){
        gitcalendar_injector_config()
        GitCalendarInit("/api?null",['#d9e0df', '#c6e0dc', '#a8dcd4', '#9adcd2', '#89ded1', '#77e0d0', '#5fdecb', '#47dcc6', '#39dcc3', '#1fdabe', '#00dab9'],'null')
    }
  </script><!-- hexo injector body_end end --></body></html>